Jump to content

WinQueryDlgItemTextLength

From EDM2
Revision as of 23:39, 30 July 2023 by Martini (talk | contribs) (Created page with "This function queries the length of the text string in a dialog item, not including any null termination character. WinQueryDlgItemTextLength(hwndDlg, idItem); ==Parameter...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function queries the length of the text string in a dialog item, not including any null termination character.

WinQueryDlgItemTextLength(hwndDlg, idItem); 

Parameters

hwndDlg (HWND) - input
Parent-window handle.
idItem (ULONG) - input
Identity of the child window whose text is to be queried.
It must be greater or equal to 0 and less or equal to 0xFFFF.

Returns

lRetLen (LONG) - returns
Length of text.
Error occurred
Other
Length of text.

Remarks

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 is the beginning of a function which processes the text which is displayed in the message text line.

#define INCL_WINDIALOGS
#define INCL_DOSMEMMGR
#include <OS2.H>
#define DID_MSGEDIT 900
void SelectMessageFromText(hwndDlg)
HWND    hwndDlg;
{

char *szTemp;
LONG  length;

    /* First get the edit text from the string */

 length = WinQueryDlgItemTextLength(hwndDlg,
                                     DID_MSGEDIT);
   /* now we know the buffer size needed. */

DosAllocMem((PPVOID)szTemp,
            (ULONG)length,
             PAG_READ |
             PAG_WRITE |
             PAG_COMMIT);

 WinQueryDlgItemText(hwndDlg,
                     DID_MSGEDIT,
                     sizeof(szTemp),
                     (PSZ)szTemp);
      /* . */
      /* . */
}
#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 queried. */
LONG     lRetLen;  /*  Length of text. */

lRetLen = WinQueryDlgItemTextLength(hwndDlg, idItem);