Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function translates the text of a specified control in a dialog box into an integer value.

Syntax

UINT GetDlgItemInt( 
  HWND 
hDlg, 
  int 
nIDDlgItem, 
  BOOL* 
lpTranslated, 
  BOOL 
bSigned
); 

Parameters

hDlg

[in] Handle to the dialog box that contains the control of interest.

nIDDlgItem

[in] Dialog item identifier that specifies the control whose text is to be translated.

lpTranslated

[out] Long pointer to a Boolean variable that receives a function success/failure value (TRUE indicates success, FALSE indicates failure).

This parameter is optional: it can be NULL. In that case, the function returns no information about success or failure.

bSigned

[in] Boolean that specifies whether the function should examine the text for a minus sign at the beginning and return a signed integer value if it finds one. TRUE specifies that this should be done, FALSE that it should not.

Return Value

If the function succeeds, the variable pointed to by lpTranslatedis set to TRUE, and the return value is the translated value of the control text.

If the function fails, the variable pointed to by lpTranslatedis set to FALSE, and the return value is zero. Note that, because zero is a possible translated value, a return value of zero does not by itself indicate failure.

If lpTranslatedis NULL, the function returns no information about success or failure.

If the bSignedparameter is TRUE, specifying that the value to be retrieved is a signed integer value, cast the return value to an inttype. To get extended error information, call GetLastError.

Remarks

The GetDlgItemIntfunction retrieves the text of the specified control by sending the control a WM_GETTEXT message. The function translates the retrieved text by stripping any extra spaces at the beginning of the text and then converting the decimal digits. The function stops translating when it reaches the end of the text or encounters a nonnumeric character.

If the bSignedparameter is TRUE, the GetDlgItemIntfunction checks for a minus sign (–) at the beginning of the text and translates the text into a signed integer value. Otherwise, the function creates an unsigned integer value.

The GetDlgItemIntfunction returns zero if the translated value is greater than INT_MAX (for signed numbers) or UINT_MAX (for unsigned numbers).

Text strings with more than 48 characters cannot be translated.

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