SetDlgItemInt function (Windows)

Switch View :
ScriptFree
SetDlgItemInt function

Applies to: desktop apps only

Sets the text of a control in a dialog box to the string representation of a specified integer value.

Syntax

BOOL WINAPI SetDlgItemInt(
  __in  HWND hDlg,
  __in  int nIDDlgItem,
  __in  UINT uValue,
  __in  BOOL bSigned
);

Parameters

hDlg [in]

Type: HWND

A handle to the dialog box that contains the control.

nIDDlgItem [in]

Type: int

The control to be changed.

uValue [in]

Type: UINT

The integer value used to generate the item text.

bSigned [in]

Type: BOOL

Indicates whether the uValue parameter is signed or unsigned. If this parameter is TRUE, uValue is signed. If this parameter is TRUE and uValue is less than zero, a minus sign is placed before the first digit in the string. If this parameter is FALSE, uValue is unsigned.

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

To set the new text, this function sends a WM_SETTEXT message to the specified control.

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
GetDlgItemInt
SetDlgItemText
WM_SETTEXT
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:
TCHAR buf[16];
wnsprintf(buf, 16, bSigned?TEXT("%i"):TEXT("%u"), uValue);
SetDlgItemText(hDlg, nIDDlgItem, buf);

so you must write your own wrapper when you need other-formatted (e.g. hexadecimal) output.