Jump to content

WinQueryDlgItemText: Difference between revisions

From EDM2
Created page with "This function queries a text string in a dialog item. ==Syntax== WinQueryDlgItemText(hwndDlg, idItem, lMaxText, pszText); ==Parameters== ;hwndDlg (HWND) - input :Parent-wi..."
 
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:


==Syntax==
==Syntax==
  WinQueryDlgItemText(hwndDlg, idItem, lMaxText, pszText);
  WinQueryDlgItemText(hwndDlg, idItem, lMaxText, pszText);


==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
;lMaxText (LONG) - input:Length of pszText.
:Identity of the child window whose text is to be queried.
:It must be greater or equal to 0.
:It must be greater or equal to 0 and less or equal to 0xFFFF.  
;pszText (PSZ) - output:Output string.
 
:This is the text string that is obtained from the dialog item.
;lMaxText (LONG) - input
:Length of pszText.
:It must be greater or equal to 0.  
 
;pszText (PSZ) - output
:Output string.
:This is the text string that is obtained from the dialog item.  


==Returns==
==Returns==
;ulRetLen (ULONG) - returns
;ulRetLen (ULONG) - returns:Actual number of characters returned.
:Actual number of characters returned.
:Error occurred
:Error occurred  
:Other
:Other
::Actual number of characters returned, not including the null-terminating character. The maximum value is (lMaxText-1).
::Actual number of characters returned, not including the null-terminating character. The maximum value is (lMaxText-1).
Line 30: Line 21:
==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001)
;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified.
:An invalid window handle was specified.


==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 40: Line 30:
<pre>
<pre>
#define INCL_WINDIALOGS
#define INCL_WINDIALOGS
#include <OS2.H>
#include <os2.h>
#define DID_MSGEDIT 900
#define DID_MSGEDIT 900
void SelectMessageFromText(hwndDlg)
void SelectMessageFromText(hwndDlg)
HWND    hwndDlg;
HWND    hwndDlg;
Line 48: Line 39:


     /* First get the edit text from the string */
     /* First get the edit text from the string */
     WinQueryDlgItemText(hwndDlg, DID_MSGEDIT, sizeof(szTemp),
     WinQueryDlgItemText(hwndDlg, DID_MSGEDIT, sizeof(szTemp), (PSZ)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    lMaxText;  /*  Length of pszText. */
PSZ      pszText;  /*  Output string. */
ULONG    ulRetLen;  /*  Actual number of characters returned. */
ulRetLen = WinQueryDlgItemText(hwndDlg, idItem, lMaxText, pszText);
</pre>
</pre>


== Related Functions==
== Related Functions==
* WinQueryDlgItemShort
* [[WinQueryDlgItemShort]]
* WinQueryDlgItemText
* [[WinQueryDlgItemTextLength]]
* 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 a text string in a dialog item.

Syntax

WinQueryDlgItemText(hwndDlg, idItem, lMaxText, pszText);

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.
lMaxText (LONG) - input
Length of pszText.
It must be greater or equal to 0.
pszText (PSZ) - output
Output string.
This is the text string that is obtained from the dialog item.

Returns

ulRetLen (ULONG) - returns
Actual number of characters returned.
Error occurred
Other
Actual number of characters returned, not including the null-terminating character. The maximum value is (lMaxText-1).

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

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
#include <os2.h>
#define DID_MSGEDIT 900

void SelectMessageFromText(hwndDlg)
HWND    hwndDlg;
{
    char    szTemp[80];

    /* First get the edit text from the string */
    WinQueryDlgItemText(hwndDlg, DID_MSGEDIT, sizeof(szTemp), (PSZ)szTemp);
      /* . */
      /* . */
}

Related Functions