RegisterWindowsMessage
-
I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.
-
I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.
Check thar you made entry in .h file. afx_msg LRESULT yourfunction(WPARAM wParam,LPARAM lParam); and your .cpp file static int gnStartMsg=....... LRESULT yourclass::yourfunction(WPARAM wParam,LPARAM lParam) hope this helps; sadhu ================== The original message was: I’ve been reading your submission on registerwindowmessage at the codeguru.com web site.
Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work.
This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message?
I want to send a message from one dialog-based exe to another.
Both exe’s have this message defined.
#define TESTMSG "TESTMSG"
Both exe’s get the message id like this, and the debugger shows both get the same value.
int gnStartMsg = RegisterWindowMessage(TESTMSG);
The sending exe then sends a message like this.
SendMessage(gnStartMsg, 0, 0);
The receiving exe has this message map and member function.
BEGIN_MESSAGE_MAP(CRegToDlg, CDialog)
//{{AFX_MSG_MAP(CRegToDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest)void CRegToDlg::OnMsgTest()
{
AfxMessageBox("I made it");
}The messagebox is never displayed.
PMCGA61201@AOL.COM
Thank you. -
I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.
The problem is this line: SendMessage(gnStartMsg, 0, 0); This sends the message right back to the CDialog that this code is in. You want to do: ::SendMessage ( hwndOtherDlg, gnStartMsg, 0, 0 ); where hwndOtherDlg is the HWND of the receiving dialog. Or, if you have a CWnd* to it, you can do: pOtherDlg->SendMessage ( gnStartMsg, 0, 0 );