Jump to content

WinQueryDlgItemTextLength: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
 
Line 54: Line 54:


==Related Functions==
==Related Functions==
* WinQueryDlgItemShort
* [[WinQueryDlgItemShort]]
* WinQueryDlgItemText
* [[WinQueryDlgItemText]]
* WinQueryDlgItemTextLength
* [[WinQueryWindowText]]
* WinQueryWindowText
* [[WinQueryWindowTextLength]]
* WinQueryWindowTextLength
* [[WinSetDlgItemShort]]
* WinSetDlgItemShort
* [[WinSetDlgItemText]]
* WinSetDlgItemText
* [[WinSetWindowText]]
* WinSetWindowText


[[Category:Win]]
[[Category:Win]]

Latest revision as of 21:16, 6 August 2023

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

Syntax

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);
      /* . */
      /* . */
}

Related Functions