GetDlgItem

This function retrieves the handle to a control in the specified dialog box.

HWND GetDlgItem( 
HWND hDlg, 
int nIDDlgItem); 

Parameters

  • hDlg
    [in] Handle to the dialog box that contains the control.
  • nIDDlgItem
    [in] Specifies the identifier of the control to be retrieved.

Return Values

The window handle of the specified control indicates success. NULL indicates failure due to an invalid dialog box handle or a nonexistent control. To get extended error information, call GetLastError.

Remarks

You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window.

The GetDlgItem function works for immediate child controls of a dialog box—it does not search through nested dialog boxes.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h   Dlgmgr.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreateWindow, CreateWindowEx, GetDlgItemInt, GetDlgItemText, GetLastError

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.