Jump to content

WinQueryDlgItemTextLength: Difference between revisions

From EDM2
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This function queries the length of the text string in a dialog item, not including any null termination character.
This function queries the length of the text string in a dialog item, not including any null termination character.
==Syntax==
==Syntax==
  WinQueryDlgItemTextLength(hwndDlg, idItem);
  WinQueryDlgItemTextLength(hwndDlg, idItem)


==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 queried.
 
: It must be greater or equal to 0 and less or equal to 0xFFFF.
; 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==
==Returns==
; lRetLen (LONG) - returns
; lRetLen (LONG) - returns: Length of text.
: Length of text.
::Error occurred
::Error occurred  
:Other
:Other
::Length of text.
::Length of text.


==Remarks==
==Remarks==
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==
Line 27: Line 23:
#define INCL_WINDIALOGS
#define INCL_WINDIALOGS
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
#include <OS2.H>
#include <os2.h>
#define DID_MSGEDIT 900
#define DID_MSGEDIT 900
void SelectMessageFromText(hwndDlg)
void SelectMessageFromText(hwndDlg)
HWND    hwndDlg;
HWND    hwndDlg;
{
{
  char *szTemp;
  LONG  length;
/* First get the edit text from the string */
  length = WinQueryDlgItemTextLength(hwndDlg, DID_MSGEDIT);


char *szTemp;
  /* now we know the buffer size needed. */
LONG  length;
 
  DosAllocMem((PPVOID)szTemp,
    /* First get the edit text from the string */
              (ULONG)length,
 
              PAG_READ |
  length = WinQueryDlgItemTextLength(hwndDlg,
              PAG_WRITE |
                                    DID_MSGEDIT);
              PAG_COMMIT);
  /* now we know the buffer size needed. */
 
  WinQueryDlgItemText(hwndDlg,
DosAllocMem((PPVOID)szTemp,
                      DID_MSGEDIT,
            (ULONG)length,
                      sizeof(szTemp),
            PAG_READ |
                      (PSZ)szTemp);
            PAG_WRITE |
            PAG_COMMIT);
 
WinQueryDlgItemText(hwndDlg,
                    DID_MSGEDIT,
                    sizeof(szTemp),
                    (PSZ)szTemp);
       /* . */
       /* . */
       /* . */
       /* . */
}
}
</pre>
<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 queried. */
LONG    lRetLen;  /*  Length of text. */
lRetLen = WinQueryDlgItemTextLength(hwndDlg, idItem);
</pre>
</pre>


==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