Sent to a window procedure when:
Message Source | HIWORD(wp) | LOWORD(wp) | lp |
---|---|---|---|
Menu | 0 | Menu ID (IDM_*) | 0 |
Accelerator | 1 | Accel ID (IDM_*) | 0 |
Control | notification code | Control id | HWND of control window |
For example, in Notepad, when a user clicks "File->Open" a dialog box is displayed to allow the user to open a file. Menu items are processed in the window procedure's WM_CREATE message like this:
LRESULT CALLBACK winproc(HWND hwnd, UINT wm, WPARAM wp, LPARAM lp)
{
switch (wm) {
case WM_COMMAND:
switch (LOWORD(wp) {
case ID_FILE_OPEN:
/* show file open dialog */
break;
case ID_FILE_NEW:
/* create new instance */
break;
}
return 0;
}
return DefWindowProc(hwnd, wm, wp, lp);
}