Share via


Handling Notification Messages (Windows Embedded CE 6.0)

1/6/2010

Every window control responds to user input or changes to the control by sending a notification message to its parent window. A notification message is a WM_COMMAND message that includes a control identifier and a notification code that identifies the nature of the event. An application must collect these notification messages and respond to them.

The following code example shows one method of trapping a WM_COMMAND message.

BOOL CALLBACK AboutDialogProc (
                        HWND hwndDlg,     // Handle to the dialog box
                        UINT uMsg,        // Message
                        WPARAM wParam,    // First message parameter
                        LPARAM lParam)    // Second message parameter
{
  switch (uMsg)
  {
    case WM_INITDIALOG:
      return TRUE;  

    case WM_COMMAND:
      switch (LOWORD (wParam))
      {
        case IDOK:
          EndDialog (hwndDlg, IDOK);
          return TRUE;

        case IDCANCEL:
          EndDialog (hwndDlg, IDCANCEL);
          return TRUE;
      }
      break;
  }
  return FALSE;
}

Some window controls receive as well as generate messages. Typically, a window procedure sends a message to a control, directing it to execute a task. The control processes the message and carries out the requested action. Windows Embedded CE 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. The following table shows these messages.

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 also is processed.

WM_GETTEXT

Process if the control text is not the same as the title that is specified by the CreateWindowEx function.

WM_GETTEXTLENGTH

Process if the control text is not the same as the title that is 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_SETFONT

Process if the control displays text. Windows Embedded CE sends this message when Windows Embedded CE creates a dialog box that has the DS_SETFONT style.

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 that is specified by the CreateWindowEx function.

You also can send messages to a control by calling the SendMessage function. One control that calls SendMessage to receive messages is the button control.

See Also

Concepts

Working with Window Controls

Other Resources

GWES Application Development