ClassWizard does not allow increasing user-defined messages, so you must be manually entered. After entering, ClassWizard can handle your custom message like processing other messages.
Below is the step of adding custom messages:
Step 1: Define the message. When developing a Windows95 application, Microsoft recommends that user-defined messages are at least WM_USER 100 because many new controls should also use WM_USER messages.
Step 2: Implement the message processing function. This function uses WPRAM and LPARAM parameters and returns lpeSult.
LpeSult CMAINFRAME :: ONMYMESSAGE (WPARAM WPARAM, LPARAM LPARAM)
{
// TODO: Handle user custom message
...
Return 0;
}
Step 3: Describe the message processing function in the AFX_MSG block of the class header:
Class CMAINFRAME: PUBLIC CMDIFRAMEWND
{
...
// General message mapping function
protected:
// {{AFX_MSG (CMAINFRAME)
AFX_MSG Int Oncreate (LPCReatestruct LPCreateStruct);
AFX_MSG Void Ontimer (uint nidEvent);
AFX_MSG LRESULT ONMYMESSAGE (WPARAM WPARAM, LPARAM LPARAM);
//}} AFX_MSG
Declare_message_map ()
}
Step 4: In the user class message block, use the ON_MESSAGE macro to map the message to the message processing function.
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 ()
If the user needs a unique message throughout the system, you can call the SDK function REGISTERWINDOWMESAGE and use the on_register_message macro to replace the ON_MESSAGE macro, the rest is the same.