Sending message to a MFC app. 
Author Message
 Sending message to a MFC app.

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



Fri, 15 Oct 1999 03:00:00 GMT  
 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



Fri, 15 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sending a message from VB-app to VC-app

2. Send a message like NET SEND in MFC

3. sending messages between apps

4. Break not seen when another app sends message

5. Sending a message from one app to another on NT

6. Sending message to CPropertySheet crashes app in Release

7. [ Access violation sending message in multi-threaded app! ]

8. Trying to send a message from one app to another

9. Sending a message from one app to another on NT

10. Send message to another App

11. Sending messages between 2 MFC applications

12. MFC: Send an error message?!?

 

 
Powered by phpBB® Forum Software