GetDlgItem

  HWND GetDlgItem(hwndDlg, nIDDlgItem)    
  HWND hwndDlg; /* handle of dialog box */
  int nIDDlgItem; /* identifier of control */

This function retrieves the handle of a control contained in the dialog box specified by the hwndDlg parameter.

Parameters

hwndDlg

Identifies the dialog box that contains the control.

nIDDlgItem

Specifies the integer ID of the item to be retrieved.

Return Value

The return value identifies the given control. It is NULL if no control with the integer ID given by the nIDDlgItem parameter exists.

Comments

The GetDlgItem function can be used with any parent-child window pair, not just dialog boxes. As long as the hwndDlg parameter specifies a parent window and the child window has a unique ID (as specified by the hMenu parameter in the CreateWindow function that created the child window), GetDlgItem returns a valid handle to the child window.

See Also

CreateWindow, GetDlgItemInt, GetDlgItemText