1. Customize the message ID.
#define Wm_my_message (wm_user+100) Wm_user is the ID reserved for the Windows system for non-system messages, at least 100, because messages from other controls take up part of the message.
2. Define the message handler function.
The message handler function is a member function of the message target class. It should first be declared in the. h file. Here, for example, the main window class, the main window class name Cmaindialog, the message handler function is declared first in CMainDialog.h.
Protected
afx_msg LRESULT onmymessage (WPARAM WPARAM, LPARAM LPARAM);
3. Implement message-handling functions in CMainDialog.cpp
Lpesult cmaindialog::onmymessage (WPARAM WPARAM, LPARAM LPARAM) {//TODO: Handling user custom Messages ... return 0;}
4. Mapping the message ID and message handler functions in CMainDialog.cpp
Begin_message_map (CMainFrame, CMDIFrameWnd)//{{afx_msg_map (CMainFrame) on_wm_create () On_wm_timer () on_message (WM_ My_message, OnMyMessage)//}}afx_msg_map End_message_map ()
When the thread is created, the main window handle is passed as a parameter to the thread, and the message can be delivered with PostMessage.
From for notes (Wiz)
MFC delivers messages with PostMessage