GetDlgItem

Syntax

HWND GetDlgItem(hDlg,nIDDlgItem)

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

Parameter Type/Description  

hDlg HWND Identifies the dialog box that contains the control.  
nIDDlgItem int 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 hDlg 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.