APPLICATION MESSAGES
Application messages:
a) MFC provides predefined message handlers for many standard Windows messages, and developers can also create custom handlers for user-defined messages (often declared starting from WM_USER or WM_APP).
a) MFC provides predefined message handlers for many standard Windows messages, and developers can also create custom handlers for user-defined messages (often declared starting from WM_USER or WM_APP).
b) Messages are related to user input (mouse clicks, keyboard presses), error messages from an application, or notifications about the status of a task.
first range: 0 through WM_USER –1
a) Message numbers in the first range (0 through WM_USER –1) are defined by the system.
b) Values in this range that are not explicitly defined are reserved by the system.
second range: WM_USER through 0x7FFF
Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class.
third range: 0x8000 through 0xBFFF
a) Message numbers in the third range (0x8000 through 0xBFFF) are available for applications to use as private messages.
b) Messages in this range do not conflict with system messages.
fourth range: 0xC000 through 0xFFFF
a) Message numbers in the fourth range (0xC000 through 0xFFFF) are defined at run time when an application calls the RegisterWindowMessage function to retrieve a message number for a string.
b) All applications that register the same string can use the associated message number for exchanging messages.
c) The actual message number, however, is not a constant and cannot be assumed to be the same between different sessions.
fifth range: greater than 0xFFFF
Message numbers in the fifth range (greater than 0xFFFF) are reserved by the system.
Example:
A) CUSTOM MESSAGE:
#define WM_CUSTOM_MESSAGE (WM_USER + 1)
ON_MESSAGE(WM_CUSTOM_MESSAGE, CustomMessageTDlg)
SendMessage(WM_CUSTOM_MESSAGE, NULL, NULL);
LRESULT CMFCAppTDlg::CustomMessageTDlg(WPARAM wParam, LPARAM lParam)
{
AfxMessageBox(_T("CustomMessageTDlg"));
return 0L;
}
B) REGISTERED MESSAGE:
static UINT WM_REGISTERED_MESSAGE = RegisterWindowMessage(_T("REGISTERED_MSG"));
ON_REGISTERED_MESSAGE(WM_REGISTERED_MESSAGE, RegisteredMessageTDlg)
SendMessage(WM_REGISTERED_MESSAGE, NULL, NULL);
LRESULT CMFCAppTDlg::RegisteredMessageTDlg(WPARAM wParam, LPARAM lParam)
{
AfxMessageBox(_T("RegisteredMessageTDlg"));
return 0L;
}
a) https://www.autoitscript.com/autoit3/docs/appendix/WinMsgCodes.htm
b) https://learn.microsoft.com/en-us/cpp/mfc/message-handling-and-mapping?view=msvc-170
c) https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/k35k2bfs(v=vs.100)?redirectedfrom=MSDN
d) https://www.codeproject.com/Articles/598/Windows-Message-Handling-Part-2