A parent window or other windows send control messages to direct a control to perform specific tasks. The window procedure processes these messages and carries out the requested action.
Control messages can be predefined or application-defined. Windows has several predefined messages, such as WM_GETTEXT and WM_GETDLGCODE, that it sends to controls. These messages typically correspond to window-management functions that carry out actions on windows. The window procedure for an application-defined control processes any predefined control message that affects the operation of the control. Such messages are described in the following table.
Message | Recommendation |
---|---|
WM_GETDLGCODE | Process if the control uses the ENTER, ESC, TAB, or arrow keys. The IsDialogMessage function sends this message to controls in a dialog box to determine whether to process the keys or pass them to the control. |
WM_GETFONT | Process if the WM_SETFONT message is also processed. |
WM_GETTEXT | Process if the control text is not the same as the title specified by the CreateWindowEx function. |
WM_GETTEXTLENGTH | Process if the control text is not the same as the title specified by the CreateWindowEx function. |
WM_KILLFOCUS | Process if the control displays a caret, a focus rectangle, or another item to indicate that it has the input focus. |
WM_SETFOCUS | Process if the control displays a caret, a focus rectangle, or another item to indicate that it has the input focus. |
WM_SETTEXT | Process if the control text is not the same as the title specified by the CreateWindowEx function. |
WM_SETFONT | Process if the control displays text. Windows CE sends this message when creating a dialog box that has the DS_SETFONT style. |
Because an application-defined control message is specific to the designated control, you must explicitly send it to the control by using the SendMessage or SendDlgItemMessage function. The numeric value for each message must be unique and must not conflict with the values of other window messages.