
Sending message to a MFC app.
Hi Steve,
Simply do the following:
From the fact that you could close the app, I will dispense with telling
you how to send the msg and just concentrate on showing you how to trap the
incoming msg. With MFC there's nothing to it.Below ID_TEST_MSG is the id of
the msg you are attempting to trap and OnTestMsg is the function that is to
be called when the msg is received.
1. Insert a handler into your app's message map section (before the
END_MESSAGE_MAP line) like this:
ON_COMMAND(ID_TEST_MSG, OnTestMsg)
2. Implement the OnTestMsg like this:
void CTestApp::OnTestMsg()
3. Declare it in the app's class (before the //}}AFX_MSG comment) like
this:
afx_msg void OnTestMsg();
That's all there is to it!
Tom Archer
Quote:
> This is probably pretty basic, but it is giving me trouble.
> I'm trying to send a user defined message to an MFC app from a separate
> application, and have the MFC app handle it. I overrode (through
> ClassWizard) PreTranslateMessage for every window in my MFC app as well
as
> for the application class, but I never see the message I send from the
2nd
> app. To test, I sent WM_CLOSE, which closed the application, but which
> never showed up in PreTranslateMessage. Another try: I ran the MFC app,
> determined the HWNDs of the windows in the MFC app through watches, an
used
> those HWNDs in SendMessage in the 2nd app. PreTranslateMessage in the
MFC
> app still didn't catch the message.
> Any advice would be appreciated.
> Steve Hulcher