WinQueryDlgItemShort: Difference between revisions
Appearance
Created page with "This function converts the text of a dialog item into an integer value. ==Syntax== WinQueryDlgItemShort(hwndDlg, idItem, psResult, fSigned); ==Parameters== ; hwndDlg (HWND..." |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 92: | Line 92: | ||
==Related Functions== | ==Related Functions== | ||
* | * [[WinQueryDlgItemText]] | ||
* [[WinQueryDlgItemTextLength]] | |||
* WinQueryDlgItemTextLength | * [[WinQueryWindowText]] | ||
* WinQueryWindowText | * [[WinQueryWindowTextLength]] | ||
* WinQueryWindowTextLength | * [[WinSetDlgItemShort]] | ||
* WinSetDlgItemShort | * [[WinSetDlgItemText]] | ||
* WinSetDlgItemText | * [[WinSetWindowText]] | ||
* WinSetWindowText | |||
[[Category:Win]] | [[Category:Win]] | ||
Latest revision as of 20:15, 6 August 2023
This function converts the text of a dialog item into an integer value.
Syntax
WinQueryDlgItemShort(hwndDlg, idItem, psResult, fSigned);
Parameters
- hwndDlg (HWND) - input
- Parent-window handle.
- idItem (ULONG) - input
- Identity of the child window whose text is to be converted.
- It must be greater or equal to 0 and less or equal to 0xFFFF.
- psResult (PSHORT) - output
- Integer value resulting from the conversion.
- fSigned (BOOL) - input
- Sign indicator.
- TRUE
- Signed text. It is inspected for a minus sign (-).
- FALSE
- Unsigned text.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful conversion
- FALSE
- Error occurred.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
This function is useful for converting a numerical input field into a binary number for further processing. The text of a dialog item is assumed to be an ASCII string.
This function is valid for any window with children. However, it is typically used for dialog items in a dialog window.
Example Code
This example gets the text from a Dialog Box entry field as an integer value.
#define INCL_WINDIALOGS
#include <OS2.H>
#define ID_ENTRYFLD 900
HAB hab;
HWND hwnd;
ULONG msg;
MPARAM mp1;
SHORT iconverted;
/* . */
switch(msg)
{
case WM_INITDLG:
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK:
WinQueryDlgItemShort(hwnd,
ID_ENTRYFLD,
&iconverted, /* integer result */
TRUE); /* Get the short */
}
}
Definition
#define INCL_WINDIALOGS /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>
HWND hwndDlg; /* Parent-window handle. */
ULONG idItem; /* Identity of the child window whose text is to be converted. */
PSHORT psResult; /* Integer value resulting from the conversion. */
BOOL fSigned; /* Sign indicator. */
BOOL rc; /* Success indicator. */
rc = WinQueryDlgItemShort(hwndDlg, idItem,
psResult, fSigned);