GetDlgCtrlID

The GetDlgCtrlID function returns the identifier of the specified control.

int GetDlgCtrlID(
  HWND hwndCtl   // handle of control
);
 

Parameters

hwndCtl
Identifies the control.

Return Values

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 identifies a top-level window, top-level windows cannot have identifiers and such a return value is never valid.

Windows CE: Identifiers are only valid for child windows.

The identifier can be set by passing it in as the hMenu parameter to the CreateWindowEx function. It can also be set and retrieved by calling the SetWindowLong and GetWindowLong functions with the nIndex parameter set to GWL_ID.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also

Dialog Boxes Overview, Dialog Box Functions, CreateWindow, CreateWindowEx, GetDlgItem