|
-
October 29th, 1999, 03:44 AM
#1
I want to send messages between 2 windows-applications. What must I do?
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.
-
October 29th, 1999, 08:01 AM
#2
Re: I want to send messages between 2 windows-applications. What must I do?
One way to do it is to use the FindWindow() function and post a mutually defined message to the other app.
-
October 29th, 1999, 08:45 AM
#3
Re: I want to send messages between 2 windows-applications. What must I do?
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;
}
-
October 29th, 1999, 11:58 AM
#4
Re: I want to send messages between 2 windows-applications. What must I do?
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
-
November 16th, 1999, 02:29 AM
#5
Re: I want to send messages between 2 windows-applications. What must I do?
Hi. I had tested your code. But did not work between 2 app. What's the prolem ?
Regards
ktpark
-
November 16th, 1999, 08:25 AM
#6
Re: I want to send messages between 2 windows-applications. What must I do?
-
November 16th, 1999, 11:20 AM
#7
Re: I want to send messages between 2 windows-applications. What must I do?
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.
-
November 16th, 1999, 08:06 PM
#8
Re: I want to send messages between 2 windows-applications. What must I do?
Hi. Thanks for your response. I got it this problem. See the link below.
http://codeguru.developer.com/bbs/wt...sb=5&category=
Thanks for all comments
Best regards
ktpark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|