WinSetDlgItemShort
Appearance
This function converts an integer value into the text of a dialog item.
Syntax
WinSetDlgItemShort(hwndDlg, idItem, usValue, fSigned)
Parameters
- hwndDlg (HWND) - input
- Parent-window handle.
- idItem (ULONG) - input
- Identity of the child window whose text is to be changed.
- It must be greater or equal to 0 and less or equal to 0xFFFF.
- usValue (USHORT) - input
- Integer value used to generate the dialog item text.
- fSigned (BOOL) - input
- Sign indicator.
- TRUE: Signed integer value
- FALSE: Unsigned integer value.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion
- FALSE: Error occurred.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
The text produced is 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 #define INCL_WINBUTTONS #include <os2.h> #define ID_ENTRYFLD 900 #define EM_SETTEXTLIMIT 2 HAB hab; HWND hwnd; ULONG msg; switch(msg) { case WM_INITDLG: /* set entry field text limit. */ WinSendDlgItemMsg(hwnd, /* identifier of the entry field window, which is */ /* a child of the the window defined by hwnd. */ (ULONG)ID_ENTRYFLD, (ULONG)EM_SETTEXTLIMIT, /* Limit length */ /* MPFROM2SHORT macro is of the form (low 2 bytes, */ /* high 2 bytes), the the number passed is simply 2. */ MPFROM2SHORT(2,0), (MPARAM)0); /* set entry field to 12. */ WinSetDlgItemShort(hwnd, ID_ENTRYFLD, (SHORT)12,TRUE); }