Board index » cppbuilder » Sending messages to TApplication...

Sending messages to TApplication...


2008-04-24 01:05:46 AM
cppbuilder48
Hay guys, just a {*word*218}, is it possible to send a custom message to the
TApplicaiton?
I was under the impression that TApplication creates a hidden message window
and when i search for it with FindWindow, i get a valid handle returned.
However, then i try to post a a custome message, it never seems to be
recieved...
My code looks like this:
// MainForm.h
#define WM_ACTIVATE_MAIN (WM_USER + 1000)
private:
void __fastcall AppProcessMessage(tagMSG &msg, bool &Handled);
// MainForm.cpp
void __fastcall TMainForm::AppProcessMessage(tagMSG &msg, bool &Handled)
{
// Global Application Message Processing / Handling switch.
switch (msg.message)
{
case WM_ACTIVATE_MAIN : Beep(1000, 2500);
Handled = true;
break;
default : Handled = false;
break;
}
}
In a secondary application, I have this:
HWND hAppFrm = FindWindow("TApplication", "ControlCentre");
if (hAppFrm)
{
PostMessage(hAppFrm, WM_ACTIVATE_MAIN, 1, 0);
}
Any ideas?
Many thanks,
Mike C
 
 

Re:Sending messages to TApplication...

P.S. I tried the same thing with HookMainWindow and i get the same result
i.e. nothing...
 

Re:Sending messages to TApplication...

"Mike Collins" <its@TheBottomOfThePost>wrote in message
Quote
I was under the impression that TApplication creates a hidden
message window
Yes, it does.
Quote
However, then i try to post a a custome message, it never seems
to be recieved...
Then you are not actually sending the message to the correct HWND. For
example, if your project is open in the IDE while your .exe is running, you
might be posting to an HWND that is inside the IDE rather in then in your
running application.
Gambit
 

{smallsort}