Article View: borland.public.cppbuilder.nativeapi
Article #508Re: How to use SetWindowsHookEx?
From: Remy Lebeau (TeamB)
Date: Wed, 19 Mar 2008 22:16
Date: Wed, 19 Mar 2008 22:16
47 lines
2299 bytes
2299 bytes
"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in message
news:47e186a4@newsgroups.borland.com...
> What HOOKPROC is (from winuser.h)
>
> typedef LRESULT (CALLBACK* HOOKPROC)(
> int code,
> WPARAM wParam,
> LPARAM lParam);
It is only declared that way when STRICT is defined, which is usually not
the case (it is not in amol's, as evident by the error message he showed).
The full declaration is as follows:
#ifdef STRICT
typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM
lParam);
#else
typedef FARPROC HOOKPROC;
#endif
FARPROC is defined in windef as follows:
#ifdef _WIN64
typedef INT_PTR (FAR WINAPI *FARPROC)();
#else
typedef int (FAR WINAPI *FARPROC)();
#endif
> Change your function to be
>
> LRESULT CALLBACK KeyboardProc(int ncode, wParam wparam, lParam lparam)
>
> so that it matches the type for which SetWindowsHookEx is supposed to
> receive.
His original declaration already matches what a keyboard hook is supposed to
use. Your change, on the other hand, won't compile.
> You are passing an HINSTANCE to the wParam argument
No, he's not. He's passing an HINSTANCE to SetWindowsHookEx(), not
KeyboardProc().
Gambit
Technical Details
Message-ID:
<47e190b8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mailReferences:
<47e0a645$1@newsgroups.borland.com> <47e186a4@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9f887c902c1804e1 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <47e0a645$1@newsgroups.borland.com> <47e186a4@newsgroups.borland.com> Subject: Re: How to use SetWindowsHookEx? Date: Wed, 19 Mar 2008 15:16:31 -0700 Lines: 49 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 207.178.157.90 Message-ID: <47e190b8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1205964984 207.178.157.90 (19 Mar 2008 15:16:24 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail