-
Basic messaging question
InInitInstance I send a message to send a message to ManFrame
but ManFrame never get the message. It looks like this,
AfxGetMainWnd()->SendMessage(UM_CREATE_THREAD, 0, 0);
In MainFrame.h I have added afx_msg void OnCreateThread();
, like below
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnFilePrint();
afx_msg void OnFilePrintPreview();
//}}AFX_MSG
afx_msg void OnCreateThread();
DECLARE_MESSAGE_MAP()
In MainFrame.cpp I have added ON_COMMAND(UM_CREATE_THREAD, OnCreateThread) like below
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
//}}AFX_MSG_MAP
ON_COMMAND(UM_CREATE_THREAD, OnCreateThread)
END_MESSAGE_MAP()
Also in MainFrame.cpp I have added
void CMainFrame::OnCreateThread()
{
AfxMessageBox("Got the message");
}
But I never get the "Got the message" printed on the screen.
What is it I'm missing. Probably this is very basic but I would be very happy for an answer.
-
ON_COMMAND is used for WM_COMMAND messages. You are using a user defined message. Change ON_COMMAND to ON_MESSAGE.
-
-
I am assuming that worked, and you're welcome.