Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Retrieves a pointer to the specified control or child window in a dialog box or other window.

CWnd* GetDlgItem(
   int nID 
) const;
void GetDlgItem(
   int nID,
   HWND* phWnd
) const;



Specifies the identifier of the control or child window to be retrieved.


A pointer to a child window.

A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.

The returned pointer may be temporary and should not be stored for later use.

The pointer returned is usually cast to the type of control identified by nID.

// uses GetDlgItem to return a pointer to a user interface control
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);

Community Additions

© 2015 Microsoft