GetDlgItemText function
Retrieves the title or text associated with a control in a dialog box.
Syntax
UINT WINAPI GetDlgItemText( _In_ HWND hDlg, _In_ int nIDDlgItem, _Out_ LPTSTR lpString, _In_ int nMaxCount );
Parameters
- hDlg [in]
-
Type: HWND
A handle to the dialog box that contains the control.
- nIDDlgItem [in]
-
Type: int
The identifier of the control whose title or text is to be retrieved.
- lpString [out]
-
Type: LPTSTR
The buffer to receive the title or text.
- nMaxCount [in]
-
Type: int
The maximum length, in characters, of the string to be copied to the buffer pointed to by lpString. If the length of the string, including the null character, exceeds the limit, the string is truncated.
Return value
Type: UINT
If the function succeeds, the return value specifies the number of characters copied to the buffer, not including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
If the string is as long or longer than the buffer, the buffer will contain the truncated string with a terminating null character.
The GetDlgItemText function sends a WM_GETTEXT message to the control.
Examples
For an example, see Creating a Modal Dialog Box.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | GetDlgItemTextW (Unicode) and GetDlgItemTextA (ANSI) |
See also
- Reference
- GetDlgItemInt
- SetDlgItemInt
- SetDlgItemText
- WM_GETTEXT
- Conceptual
- Dialog Boxes