GetDlgCtrlID function (Windows)

Switch View :
ScriptFree
GetDlgCtrlID function

Applies to: desktop apps only

Retrieves the identifier of the specified control.

Syntax

int WINAPI GetDlgCtrlID(
  __in  HWND hwndCtl
);

Parameters

hwndCtl [in]

Type: HWND

A handle to the control.

Return value

Type: int

If the function succeeds, the return value is the identifier of the control.

If the function fails, the return value is zero. An invalid value for the hwndCtl parameter, for example, will cause the function to fail. To get extended error information, call GetLastError.

Remarks

GetDlgCtrlID accepts child window handles as well as handles of controls in dialog boxes. An application sets the identifier for a child window when it creates the window by assigning the identifier value to the hmenu parameter when calling the CreateWindow or CreateWindowEx function.

Although GetDlgCtrlID may return a value if hwndCtl is a handle to a top-level window, top-level windows cannot have identifiers and such a return value is never valid.

Examples

For an example, see Initializing a Dialog Box.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
CreateWindow
CreateWindowEx
GetDlgItem
Conceptual
Dialog Boxes

 

 

Send comments about this topic to Microsoft

Build date: 2/10/2012

Community Content

Henrik Haftmann
More remarks
This function performs like:
GetWindowLong(hwndCtl,GWL_ID)
where the ID is the hMenu parameter in CreateWindowEx() call.
That's the reason why this function should only be called for child windows.

Đonny
Visual Basic 10 declaration
Private Declare Auto Function GetDlgCtrlID Lib"User32.dll" (ByVal hwndCtl As IntPtr) As Integer