Jump to content

WinSetDlgItemShort: Difference between revisions

From EDM2
Created page with "This function converts an integer value into the text of a dialog item. ==Syntax== WinSetDlgItemShort(hwndDlg, idItem, usValue, fSigned); ==Parameters== ;hwndDlg (HWND) - in..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function converts an integer value into the text of a dialog item.
This function converts an integer value into the text of a dialog item.
==Syntax==
==Syntax==
  WinSetDlgItemShort(hwndDlg, idItem, usValue, fSigned);
  WinSetDlgItemShort(hwndDlg, idItem, usValue, fSigned)


==Parameters==
==Parameters==
;hwndDlg (HWND) - input
;hwndDlg (HWND) - input:Parent-window handle.
: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.
;idItem (ULONG) - input
;usValue (USHORT) - input:Integer value used to generate the dialog item text.
:Identity of the child window whose text is to be changed.
;fSigned (BOOL) - input:Sign indicator.
:It must be greater or equal to 0 and less or equal to 0xFFFF.  
::TRUE: Signed integer value
 
::FALSE: Unsigned integer value.
;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==
==Returns==
; rc (BOOL) - returns
;rc (BOOL) - returns:Success indicator.
:Success indicator.
::TRUE: Successful completion
 
::FALSE: Error occurred.
:;TRUE
::Successful completion  
:;FALSE
::Error occurred.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified.


;PMERR_INVALID_HWND (0x1001)
:An invalid window handle was specified.
==Remarks==
==Remarks==
The text produced is an ASCII string.
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.  
This function is valid for any window with children; however, it is typically used for dialog items in a dialog window.
 
==Example Code==
==Example Code==
This example gets the text from a Dialog Box entry field as an integer value.
This example gets the text from a Dialog Box entry field as an integer value.
Line 46: Line 32:
#define INCL_WINDIALOGS
#define INCL_WINDIALOGS
#define INCL_WINBUTTONS
#define INCL_WINBUTTONS
#include <OS2.H>
#include <os2.h>
#define ID_ENTRYFLD 900
#define ID_ENTRYFLD 900
#define EM_SETTEXTLIMIT 2
#define EM_SETTEXTLIMIT 2
Line 71: Line 57:
   WinSetDlgItemShort(hwnd, ID_ENTRYFLD, (SHORT)12,TRUE);
   WinSetDlgItemShort(hwnd, ID_ENTRYFLD, (SHORT)12,TRUE);
   }
   }
</pre>
Definition
<pre>
#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 changed. */
USHORT    usValue;  /*  Integer value used to generate the dialog item text. */
BOOL      fSigned;  /*  Sign indicator. */
BOOL      rc;      /*  Success indicator. */
rc = WinSetDlgItemShort(hwndDlg, idItem, usValue, fSigned);
</pre>
</pre>



Latest revision as of 07:19, 7 August 2023

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);
  }

Related Functions