#1
A dlgproc should return TRUE
if it processes the message, otherwise FALSE.
The default return value should therefore usually be FALSE (for all the stuff you don't handle). You override this for the stuff you do handle.
If you don't handle WM_CLOSE yourself, i.e. return FALSE in respose to a WM_CLOSE close message, then the dialog manager's message processing will handle it for you. If you return TRUE in response to WM_CLOSE you will stop the dialog manager from performing the default handling.
The default routine does not handle WM_DESTROY. I assume this is because quitting an app is belived to be something that should be under the control of the app writer.
#2
The WM_COMMAND is not just for menus. It's a message which allows you to send a command, which is used by the standard menus, (older) controls, and accelerator.
That is, while WM_COMMAND messages can come from a menu entry, they can also come from -- other -- controls (e.g. button, combobox, edit, static, ...) and accelerators. And there's nothing stopping you from sending custom WM_COMMAND messages internally if you want to.
The data sent with WM_COMMAND is a command ID (identifying the menu item, control, or accelertator entry) plus, in the case of a control, the control's window handle and a notification code (e.g. for a button BN_CLICK, BN_DBLCLK, ...; for an Edit control EN_CHANGE, EN_SETFOCUS, ...; ...).
(Instead of the notification code, message from menus contain a 0 and those from an acelerator, 1).
Andy
PPS The newer controls from comctl32.dll use WM_NOTIFY instead of WM_COMMAND. The notification message provides a more flexible way of passing data (instead of id, notification code, and hwnd, it uses structures (passed by address) which all use a standard header.
PS To quote MSDN directly:
Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message. |
From:
DialogProc callback function (Windows)
http://msdn.microsoft.com/en-gb/library/windows/desktop/ms645469%28v=vs.85%29.aspx