K
kid joe
Hi,
I'm trying hooks for the first time and having a bit
of a nightmare.
I basically want to trap when other windows are resized,
moved etc. When i set a WH_CBT hook it runs ok, but never
seems to execute.
When i set WH_CALLWNDPROC my machine goes mad and
i have to reboot, im using VC++6 on win2k bbut had similar experience on
win95.
The code im using is below. It looks OK to me, but obviously it isnt!
Any help would be appreciated.
Cheers
Joe
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_POPUP|WS_SYSMENU,
0, -200, ww, hh, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hhk = SetWindowsHookEx(WH_CBT,CallWndProc,hInstance,0);
// hhk = SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,hInstance,0);
theWnd = hWnd;
return TRUE;
}
LRESULT CALLBACK CallWndProc(
int nCode, // hook code
WPARAM wParam, // depends on hook code
LPARAM lParam // depends on hook code
)
{
if(nCode>=0)
{
grabit=2;
}
return CallNextHookEx(hhk, nCode, wParam, lParam );
}
--
.--------------------.
| |
| Good Evening.... | .--.--.
| | .; .;|;. ;.
`-------------. ,---' .;_;' `;_;.
\| ; ;' `; ;
\ ;;'.--.___.--.`;;
;-( o )=( o )-;
( `--' | `--' )
\| . . |/
........... . .:::::. . .______
/ . '---` . '\
.' `. .' \
| ____,.- . | `.....' | _______ |
| ,-' \ /|\'' \.-- |
| / \.'\ /,'. \. - |
| /| ` `\ / \ |
| ,/ _ '/ '\ |
,-' ,-. |o '
/ '| | | | \
/ ,/| |o | \ `
| .' | |.' |. \ \
________/ .'____|________________________||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`
I'm trying hooks for the first time and having a bit
of a nightmare.
I basically want to trap when other windows are resized,
moved etc. When i set a WH_CBT hook it runs ok, but never
seems to execute.
When i set WH_CALLWNDPROC my machine goes mad and
i have to reboot, im using VC++6 on win2k bbut had similar experience on
win95.
The code im using is below. It looks OK to me, but obviously it isnt!
Any help would be appreciated.
Cheers
Joe
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_POPUP|WS_SYSMENU,
0, -200, ww, hh, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hhk = SetWindowsHookEx(WH_CBT,CallWndProc,hInstance,0);
// hhk = SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,hInstance,0);
theWnd = hWnd;
return TRUE;
}
LRESULT CALLBACK CallWndProc(
int nCode, // hook code
WPARAM wParam, // depends on hook code
LPARAM lParam // depends on hook code
)
{
if(nCode>=0)
{
grabit=2;
}
return CallNextHookEx(hhk, nCode, wParam, lParam );
}
--
.--------------------.
| |
| Good Evening.... | .--.--.
| | .; .;|;. ;.
`-------------. ,---' .;_;' `;_;.
\| ; ;' `; ;
\ ;;'.--.___.--.`;;
;-( o )=( o )-;
( `--' | `--' )
\| . . |/
........... . .:::::. . .______
/ . '---` . '\
.' `. .' \
| ____,.- . | `.....' | _______ |
| ,-' \ /|\'' \.-- |
| / \.'\ /,'. \. - |
| /| ` `\ / \ |
| ,/ _ '/ '\ |
,-' ,-. |o '
/ '| | | | \
/ ,/| |o | \ `
| .' | |.' |. \ \
________/ .'____|________________________||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`