Click here to Skip to main content
15,919,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: creating dialogs in a loop Pin
K. Sushilkumar7-Dec-08 21:35
K. Sushilkumar7-Dec-08 21:35 
GeneralRe: creating dialogs in a loop Pin
Randor 7-Dec-08 22:38
professional Randor 7-Dec-08 22:38 
GeneralRe: creating dialogs in a loop Pin
K. Sushilkumar7-Dec-08 22:58
K. Sushilkumar7-Dec-08 22:58 
AnswerRe: creating dialogs in a loop Pin
Iain Clarke, Warrior Programmer8-Dec-08 0:42
Iain Clarke, Warrior Programmer8-Dec-08 0:42 
GeneralRe: creating dialogs in a loop Pin
K. Sushilkumar8-Dec-08 1:46
K. Sushilkumar8-Dec-08 1:46 
GeneralRe: creating dialogs in a loop Pin
Iain Clarke, Warrior Programmer8-Dec-08 2:11
Iain Clarke, Warrior Programmer8-Dec-08 2:11 
AnswerRe: creating dialogs in a loop Pin
David Crow8-Dec-08 3:51
David Crow8-Dec-08 3:51 
QuestionHook on a HWND Pin
Tony Pottier7-Dec-08 19:22
Tony Pottier7-Dec-08 19:22 
Hello,

I'm writting a C++ DLL Hook to read any message to any program, so I'm using
SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, handleInstance, 0);

Then, in my CallWndProc, I need to filter the data coming so I can read the messages from the window I want, but it's not working as expected. During my tests, I wanted to read the messages from the HWND 0x00020afa, so if I put in the CallWndProc:

LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    if(nCode < 0)
        return CallNextHookEx(handleHook, nCode, wParam, lParam);

    CWPSTRUCT* cwpstruct = (CWPSTRUCT*)lParam;

    if((HWND)0x00020afa == cwpstruct->hwnd)
    {
        MessageBox(NULL, "TEST","LOL",MB_OK);
    }

    return CallNextHookEx(handleHook, nCode, wParam, lParam);
}


I would get the message boxes popping like crazy, but then I decided to add a global HWND to my dll:
HWND hWindow;

And then a stupid function to set it:
VOID __stdcall HookHwnd(HWND hWnd)
{
	hWindow = hWnd;
}


So I can choose which HWND i want to track with
if(hWindow == cwpstruct->hwnd) instead of if((HWND)0x00020afa == cwpstruct->hwnd)

... But it doesn't work. Am I doing something wrong here? I'm new to the dll world. Also, is this the correct way to read the messages from a window?

Thanks!
AnswerRe: Hook on a HWND Pin
Malli_S7-Dec-08 19:40
Malli_S7-Dec-08 19:40 
GeneralRe: Hook on a HWND Pin
Tony Pottier7-Dec-08 20:15
Tony Pottier7-Dec-08 20:15 
GeneralRe: Hook on a HWND Pin
Randor 7-Dec-08 20:34
professional Randor 7-Dec-08 20:34 
GeneralRe: Hook on a HWND Pin
Tony Pottier7-Dec-08 20:45
Tony Pottier7-Dec-08 20:45 
AnswerRe: Hook on a HWND Pin
Randor 7-Dec-08 19:49
professional Randor 7-Dec-08 19:49 
GeneralRe: Hook on a HWND Pin
Tony Pottier7-Dec-08 20:16
Tony Pottier7-Dec-08 20:16 
QuestionAccess system Folder Pin
john56327-Dec-08 18:59
john56327-Dec-08 18:59 
AnswerRe: Access system Folder Pin
enhzflep7-Dec-08 19:20
enhzflep7-Dec-08 19:20 
GeneralRe: Access system Folder Pin
john56328-Dec-08 0:09
john56328-Dec-08 0:09 
QuestionKeyboard Handlers Pin
prithaa7-Dec-08 18:19
prithaa7-Dec-08 18:19 
GeneralRe: Keyboard Handlers Pin
Malli_S7-Dec-08 20:02
Malli_S7-Dec-08 20:02 
QuestionStatic font Pin
NewVC++7-Dec-08 18:08
NewVC++7-Dec-08 18:08 
AnswerRe: Static font Pin
Hamid_RT7-Dec-08 18:21
Hamid_RT7-Dec-08 18:21 
GeneralRe: Static font Pin
NewVC++7-Dec-08 18:23
NewVC++7-Dec-08 18:23 
GeneralRe: Static font Pin
Hamid_RT7-Dec-08 18:30
Hamid_RT7-Dec-08 18:30 
GeneralRe: Static font Pin
NewVC++7-Dec-08 18:40
NewVC++7-Dec-08 18:40 
GeneralYou're welcome Pin
Hamid_RT7-Dec-08 18:52
Hamid_RT7-Dec-08 18:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.