Article View: borland.public.cppbuilder.nativeapi
Article #7531Re: SetWindowsHookEx
From: JD
Date: Fri, 28 Jan 2005 17:21
Date: Fri, 28 Jan 2005 17:21
44 lines
2405 bytes
2405 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote:
>
>Also, how you method reacts on Win+D
>combination that Minimizes all windows?
Arrrg. It misses it!! But it doesn't create any problems
either. I'll have to investigate that now. Thanks alot [not]!!
>> Can you please drop the sample code for that. I
>> suppose I'll neede it sooner or later.
It's actually quite simple - just like subclassing the form's
WndProc method except that you're targetting the Application
instance instead of the main form and it's a hook so it
returns a value (a bool in this case):
//--- in the header -------------------------------------------
protected:
bool __fastcall MyHookWndProc(TMessage &Message);
//--- in the unit ---------------------------------------------
__fastcall TMyClass::TMyClass( TComponent *Owner ) : TComponent(Owner)
{
Application->HookMainWindow( MyHookWndProc );
}
//-------------------------------------------------------------
__fastcall TMyClass::~TMyClass()
{
Application->UnhookMainWindow( MyHookWndProc );
}
//-------------------------------------------------------------
bool __fastcall TMyClass::MyHookWndProc( TMessage &Message )
{
if( Message.Msg == WM_something )
{
// return true if you handle the message
}
// return false to continue propagation of the message
return false;
}
//-------------------------------------------------------------
~ JD
Technical Details
Message-ID:
<41fa7490$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41f9fdbd$1@newsgroups.borland.com> <41fa2f81$1@newsgroups.borland.com> <41fa51cd@newsgroups.borland.com> <41fa578f@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5f60c991e080790d X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: SetWindowsHookEx Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.158.236.192 References: <41f9fdbd$1@newsgroups.borland.com> <41fa2f81$1@newsgroups.borland.com> <41fa51cd@newsgroups.borland.com> <41fa578f@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <41fa7490$1@newsgroups.borland.com> Date: 28 Jan 2005 09:21:20 -0800 X-Trace: newsgroups.borland.com 1106932880 207.105.83.66 (28 Jan 2005 09:21:20 -0800) Lines: 45 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail