GetDlgItemInt

Syntax

WORD GetDlgItemInt(hDlg,nIDDlgItem,lpTranslated,bSigned)

This function translates the text of a control in the given dialog box into an integer value. The GetDlgItemInt function retrieves the text of the control identified by the nIDDlgItem parameter. It translates the text by stripping any extra spaces at the beginning of the text and converting decimal digits, stopping the translation when it reaches the end of the text or encounters any nonnumeric character. If the bSigned parameter is nonzero, 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.

GetDlgItemInt returns zero if the translated number is greater than 32,767 (for signed numbers) or 65,535 (for unsigned). When errors occur, such as encountering nonnumeric characters and exceeding the given maximum, GetDlgItemInt copies zero to the location pointed to by the lpTranslated parameter. If there are no errors, lpTranslated receives a nonzero value. If lpTranslated is NULL, GetDlgItemInt does not warn about errors. GetDlgItemInt sends a WM_GETTEXT message to the control.

Parameter Type/Description  

hDlg HWND Identifies the dialog box.  
nIDDlgItem int Specifies the integer identifier of the dialog-box item to be translated.  
lpTranslated BOOL FAR * Points to the Boolean variable that is to receive the translated flag.  
bSigned BOOL Specifies whether the value to be retrieved is signed.  

Return Value

The return value specifies the translated value of the dialog-box item text. Since zero is a valid return value, the lpTranslated parameter must be used to detect errors. If a signed return value is desired, it should be cast as an int type.