PostMessage(HWND_BROADCAST, MY_CUSTOM_MESSAGE, wParam, lParam);
return CallNextHookEx(KeyHook, nCode, wParam, lParam);
}
...
This is how I get the posted message:
//APP
....
_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. Another example is Microsoft Word 2003. When I try to type it
freezes up like when I try to type on my form (obviously Word reads
HWND_BROADCAST messages). If I try to press a key in any windows that
reads HWND_BROADCAST messages everything freezes up. What is wrong
with the code?
Thanks,
Luka!