Export (0) Print
Expand All
Expand Minimize

CWnd::GetDlgItemInt

Retrieves the text of the control identified by nID.

UINT GetDlgItemInt(
   int nID,
   BOOL* lpTrans = NULL,
   BOOL bSigned = TRUE 
) const;

Parameters

nID
Specifies the integer identifier of the dialog-box control to be translated.
lpTrans
Points to the Boolean variable that is to receive the translated flag.
bSigned
Specifies whether the value to be retrieved is signed.

Return Value

Specifies the translated value of the dialog-box item text. Since 0 is a valid return value, lpTrans must be used to detect errors. If a signed return value is desired, cast it as an int type.

The function returns 0 if the translated number is greater than INT_MAX (for signed numbers) or UINT_MAX (for unsigned).

When errors occur, such as encountering nonnumeric characters and exceeding the above maximum, GetDlgItemInt copies 0 to the location pointed to by lpTrans. If there are no errors, lpTrans receives a nonzero value. If lpTrans is NULL, GetDlgItemInt does not warn about errors.

Remarks

It translates the text of the specified control in the given dialog box into an integer value by stripping any extra spaces at the beginning of the text and converting decimal digits. It stops the translation when it reaches the end of the text or encounters any nonnumeric character.

If bSigned is TRUE, GetDlgItemInt checks for a minus sign (–) at the beginning of the text and translates the text into a signed number. Otherwise, it creates an unsigned value.

It sends a WM_GETTEXT message to the control.

See Also

CWnd Overview | Class Members | Hierarchy Chart | CWnd::GetDlgItemText | GetDlgItemInt

Show:
© 2014 Microsoft