Trying to send a message from one app to another 
Author Message
 Trying to send a message from one app to another

I am using Visual C++ 4.2 and Windows NT.  I am programming with the MFC.
I am trying to send a message from one app to another.  I have used the
Win32 API PostMessage and SendNotifyMessage using HWND_BROADCAST for the
first parameter to send the message.  I placed the message handler in
CMainFrame and used ON_MESSAGE in the message map.  The message does not
appear to be getting to it's destination.  Any advice would be greatly
appreciated.  Thank you.



Mon, 03 Jan 2000 03:00:00 GMT  
 Trying to send a message from one app to another

Quote:

>  I am also having the same problem.
> see message  "Sending a message from one app to another on NT" dated 18/7/97

> I have tried DDE_EXECUTE, WM_COPYDATA and what you have done, to no success


> >I am using Visual C++ 4.2 and Windows NT.  I am programming with the MFC.
> >I am trying to send a message from one app to another.  I have used the
> >Win32 API PostMessage and SendNotifyMessage using HWND_BROADCAST for the
> >first parameter to send the message.  I placed the message handler in
> >CMainFrame and used ON_MESSAGE in the message map.  The message does not
> >appear to be getting to it's destination.  Any advice would be greatly
> >appreciated.  Thank you.

PostMessage with a user-defined message or SendMessage with WM_COPYDATA
work fine.  First you have to control the receiving app's window class
name by calling AfxRegisterClass in InitInstance and setting the
cs.lpszClass parameter in the mainframe's PreCreateWindow.  Check it
with Spy++ to make sure you have set the mainframe's class name.

Then the sending app does:
#define WM_MY_MESSAGE (WM_APP + 1234)
        CWnd* pOtherApp = FindWindow(TARGET_APP_WINCLASS_STRING, 0);
        if (pOtherApp)
        {  pOtherApp->PostMessage(WM_MY_MESSAGE, n1, n2);
                -- or --
           pOtherApp->SendMessage(WM_COPYDATA, (WPARAM)m_hWnd, (LPARAM)&cds);
        }

and the receiving app uses ON_MESSAGE in the mainframe message map (put
it outside of the class wizard comments, just before END_MESSAGE_MAP().



Sun, 09 Jan 2000 03:00:00 GMT  
 Trying to send a message from one app to another

I have managed to send data via the WM_COPYDATA.
I added a function within my mainframe to handle the WM_COPYDATA message.

Not sure why it didn't work the first time I tried this approach,

Anyway, many thanks for all your help.

Andrew Nyunt


Quote:

>PostMessage with a user-defined message or SendMessage with WM_COPYDATA
>work fine.  First you have to control the receiving app's window class
>name by calling AfxRegisterClass in InitInstance and setting the
>cs.lpszClass parameter in the mainframe's PreCreateWindow.  Check it
>with Spy++ to make sure you have set the mainframe's class name.

>Then the sending app does:
>#define WM_MY_MESSAGE (WM_APP + 1234)
> CWnd* pOtherApp = FindWindow(TARGET_APP_WINCLASS_STRING, 0);
> if (pOtherApp)
> {  pOtherApp->PostMessage(WM_MY_MESSAGE, n1, n2);
> -- or --
>    pOtherApp->SendMessage(WM_COPYDATA, (WPARAM)m_hWnd, (LPARAM)&cds);
> }

>and the receiving app uses ON_MESSAGE in the mainframe message map (put
>it outside of the class wizard comments, just before END_MESSAGE_MAP().



Mon, 10 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

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

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

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

4. Error when trying to send a message to a private queue in another domain

5. Send focus message from one control to another?

6. Sending a simple message from one PC to another over network

7. how does one know which scroll bar sent message

8. Can one send a ON_COMMAND Message?

9. Send focus message from one control to another?

10. Send focus message from one control to another?

11. Sending messages from one window to another running in a seperate thread

12. how to send a message to one client ?

 

 
Powered by phpBB® Forum Software