SetDlgItemTextW function (winuser.h)

Sets the title or text of a control in a dialog box.

Syntax

BOOL SetDlgItemTextW(
  [in] HWND    hDlg,
  [in] int     nIDDlgItem,
  [in] LPCWSTR lpString
);

Parameters

[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The control with a title or text to be set.

[in] lpString

Type: LPCTSTR

The text to be copied to the control.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The SetDlgItemText function sends a WM_SETTEXT message to the specified control.

Examples

For an example, see Using List Boxes.

Note

The winuser.h header defines SetDlgItemText as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also

Conceptual

Dialog Boxes

GetDlgItemInt

GetDlgItemText

Reference

SetDlgItemInt

WM_SETTEXT