Article View: borland.public.cppbuilder.nativeapi
Article #691Re: Hook
From: Luka Gabri�
Date: Sat, 23 Feb 2008 22:44
Date: Sat, 23 Feb 2008 22:44
38 lines
2357 bytes
2357 bytes
I've compiled a keyhook applicaton. DLL sends keys pressed to APP using:
LRESULT CALLBACK KeyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode<0 || (lParam & 0x80000000) || (lParam & 0x40000000) )
return CallNextHookEx(KeyHook, nCode, wParam, lParam);
PostMessage(HWND_BROADCAST, MY_CUSTOM_MESSAGE, wParam, lParam);
return CallNextHookEx(KeyHook, nCode, wParam, lParam);
}
This is how I get the posted message:
_fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner)
{
MY_CUSTOM_MESSAGE = NULL;
FCustomMessage = "MyMessage";
MY_CUSTOM_MESSAGE = ::RegisterWindowMessage( FCustomMessage.c_str() );
Application->OnMessage = AppMessage;
}
void __fastcall TForm2::AppMessage( TMsg &Msg, bool &Handled )
{
if( (Msg.message == MY_CUSTOM_MESSAGE) && (MY_CUSTOM_MESSAGE != 0) )
{
Handled = true;
Label1->Caption = "wParam: " + IntToStr(Msg.wParam);
Label2->Caption = "lParam: " + IntToStr(Msg.lParam);
Form2->Show();
}
}
Everything works fine when my APP is hidden or Form is not in focus, but
when i try to press a key on my form, in edit box or anywhere, the APP
freezes. Why is that?
Luka
Technical Details
Message-ID:
<47c0a17f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<475d84cf$1@newsgroups.borland.com> <475da9e2@newsgroups.borland.com> <47602d0f$1@newsgroups.borland.com> <47604449$1@newsgroups.borland.com> <476c2f5d$1@newsgroups.borland.com> <476c36ab$1@newsgroups.borland.com> <47770bc7$1@newsgroups.borland.com> <47788701@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,21ca95ce6b673016 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Luka Gabri�" <luka.gabric@gmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <475d84cf$1@newsgroups.borland.com> <475da9e2@newsgroups.borland.com> <47602d0f$1@newsgroups.borland.com> <47604449$1@newsgroups.borland.com> <476c2f5d$1@newsgroups.borland.com> <476c36ab$1@newsgroups.borland.com> <47770bc7$1@newsgroups.borland.com> <47788701@newsgroups.borland.com> Subject: Re: Hook Date: Sat, 23 Feb 2008 23:44:38 +0100 Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 89.201.136.155 Message-ID: <47c0a17f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1203806591 89.201.136.155 (23 Feb 2008 14:43:11 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail