Handling Windows Messages


2006-08-24 02:37:39 AM
cppbuilder22
I need to interface with a dll writen using visual c++. After a bit of
tinkering I am linking to it fine and can execute functions within it.
However the dll communicates back to my program using windows messages.
I tried setting the TApplication::OnMessage event to trap the messages,
but in the help it says that it only traps messages on the message que
and not ones sent directly using the win api SendMessage function. I
know that the dll uses that function.
So I don't know how to trap the messages sent to my control. The dll
has a function to initialize the messages that takes two parameters, a
HWND handle to the window to receive messages and a UINT that defines
the message id, for example WM_USER + 50. The handle I'm passing in is
my Application->Handle .
I also tried within my form mapping a custom handler like this:
class TForm1 : public TForm
{
protected:
void __fastcall CMOnMessage(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_PFCSBASE, TMessage, CMOnMessage)
END_MESSAGE_MAP(TForm)
};
void __fastcall TForm1::CMOnMessage(TMessage &Message)
{
//event code here
}
but that didn't seem to work either.
Any suggestions? There must be a way to do this...