October 29th, 1999, 03:44 AM
Both applications are written in C++. The first application must send a message and the other application must react if the message is sent. Any help is appreciated.
|
Click to See Complete Forum and Search --> : I want to send messages between 2 windows-applications. What must I do? October 29th, 1999, 03:44 AM Both applications are written in C++. The first application must send a message and the other application must react if the message is sent. Any help is appreciated. Michael Owen October 29th, 1999, 08:01 AM One way to do it is to use the FindWindow() function and post a mutually defined message to the other app. Serguei Batchila October 29th, 1999, 08:45 AM Here is the sample (not the only way, I guess, but I would use it) // 1. In your application-sender: UINT Message2Send = ::RegisterWindowMessage("STR_CoolMessage"); // 2. In your application - receiver: UINT Message2Receive = ::RegisterWindowMessage("STR_CoolMessage"); // Note: the trick is to register messages using EXACTLY THE SAME // string in both applications: Windows will return THE SAME value. // 3. In your application-sender: ::SendMessage(HWND_BROADCAST, Message2Send, (WPARAM)0, (LPARAM)0); // This call will send the message for all top-level windows in the system, see Help // 4. The rest is to catch and handle the message in application - receiver: // In you MainFrame declare function-handler afx_msg LRESULT OnCoolMessage(WPARAM WParam, LPARAM LParam); // In message map of your MainFrame add this entry ON_REGISTERED_MESSAGE(Message2Receive, OnCoolMessage) // And add implementation: LRESULT CMainFrame::OnCoolMessage(WPARAM WParam, LPARAM LParam) { AfxMessageBox("COOL!"); return (LRESULT)0; } shankar October 29th, 1999, 11:58 AM Hi, Use the user defined messages. In the first app define a message with WM_USER + ... i.e #define WM_MYMSG WM_USER+1 Same in the second app. Handle the messages with appropriate functions. Call the SendMessage with ur own MessageHandler i.e SendMessage(WM_MYMSG, .......) Hope this helps Shankar ktpark November 16th, 1999, 01:29 AM Hi. I had tested your code. But did not work between 2 app. What's the prolem ? Regards ktpark Sadhu November 16th, 1999, 07:25 AM Check out this link http://codeguru.developer.com/bbs/wt/showpost.pl?Board=vc&Number=59995&page=3&view=collapsed&sb=5 sadhu Serguei Batchila November 16th, 1999, 10:20 AM Hi I don't know why, but SendMessage(HWND_BROADCAST, ... ) really doesnt work. You can use PostMessage instead (parameters are the same). I works, I've tested it. ktpark November 16th, 1999, 07:06 PM Hi. Thanks for your response. I got it this problem. See the link below. http://codeguru.developer.com/bbs/wt/showpost.pl?Board=vc&Number=61261&page=0&view=expanded&mode=threaded&sb=5&category= Thanks for all comments Best regards ktpark codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |