Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Hooks problem

Reply
Thread Tools

Hooks problem

 
 
kid joe
Guest
Posts: n/a
 
      11-21-2008
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,hInsta nce,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 | \ `
| .' | |.' |. \ \
________/ .'____|________________________||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`



 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      11-21-2008
kid joe <> writes:

> 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.


This is Windows-specific, so you will probably get better
responses if you ask about it in a Windows programming newsgroup.
--
"C has its problems, but a language designed from scratch would have some too,
and we know C's problems."
--Bjarne Stroustrup
 
Reply With Quote
 
 
 
 
Andrew Smallshaw
Guest
Posts: n/a
 
      11-24-2008
On 2008-11-21, Ben Pfaff <> wrote:
>
> This is Windows-specific, so you will probably get better
> responses if you ask about it in a Windows programming newsgroup.


It also looks suspiciously like C++ to me as well.

--
Andrew Smallshaw

 
Reply With Quote
 
Bartc
Guest
Posts: n/a
 
      11-24-2008

"Andrew Smallshaw" <> wrote in message
news:...
> On 2008-11-21, Ben Pfaff <> wrote:
>>
>> This is Windows-specific, so you will probably get better
>> responses if you ask about it in a Windows programming newsgroup.

>
> It also looks suspiciously like C++ to me as well.


Probably not; I could understand the code.

--
Bartc

 
Reply With Quote
 
Andrew Smallshaw
Guest
Posts: n/a
 
      11-24-2008
On 2008-11-24, Bartc <> wrote:
>
> "Andrew Smallshaw" <> wrote in message
> news:...
>>
>> It also looks suspiciously like C++ to me as well.

>
> Probably not; I could understand the code.


It is possible that this is a C99 program, but if so there are an
awful lot of typedefs and a misleading reference to classes. I
suspect it may actually be C+. This is a curious language common
amongst Windows programmers that uses all the syntactic crud of
C++ while having the structure of a straight C program. This
negates any of the benefits of using C++ is the first place.

--
Andrew Smallshaw

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are there any Modelsim hooks to allow testbench code to figure out procedure call stack? Andrew FPGA VHDL 7 11-01-2008 07:26 PM
PooledExecutor and timing tasks (before/after hooks)? OtisUsenet Java 0 04-28-2006 08:16 PM
how do u remove Jconsole and hooks from application program? U. George Java 0 04-02-2006 06:04 PM
hooks.dll Terry Computer Support 3 12-06-2004 07:08 PM
Help on import hooks Gonçalo Rodrigues Python 0 11-16-2003 11:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57