共用方式為


GetDlgCtrlID

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function returns the identifier of the specified control.

Syntax

int GetDlgCtrlID( 
  HWND hwndCtl
); 

Parameters

  • hwndCtl
    [in] Handle to the control.

Return Value

The identifier of the control indicates success. Zero indicates failure. An invalid value for the hwndCtl parameter, for example, will cause the function to fail. To get extended error information, call GetLastError.

Remarks

Identifiers are only valid for child windows. An application sets the identifier 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.

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.

Requirements

Header winuser.h
Library Dlgmgr.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

CreateWindow
CreateWindowEx
GetDlgItem
GetWindowLong
SetWindowLong
Dialog Boxes Functions