WinQueryWindowText: Difference between revisions
Created page with "This function copies window text into a buffer. ==Syntax== WinQueryWindowText(hwnd, lLength, pun); ==Parameters== ;hwnd (HWND) - input :Window handle. :If hwnd is a frame-w..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function copies window text into a buffer. | This function copies window text into a buffer. | ||
==Syntax== | ==Syntax== | ||
WinQueryWindowText(hwnd, lLength, pun) | |||
==Parameters== | ==Parameters== | ||
;hwnd (HWND) - input | ;hwnd (HWND) - input:Window handle. | ||
:Window handle. | :If hwnd is a frame-window handle, the title-bar window text is copied. | ||
:If hwnd is a frame-window handle, the title-bar window text is copied. | ;lLength (LONG) - input: Length of pun. | ||
: It must be greater than 0. | |||
; lLength (LONG) - input | ;pun (PUN) - output:Window text. | ||
: Length of pun. | |||
: It must be greater than 0. | |||
;pun (PUN) - output | |||
:Window text. | |||
==Returns== | ==Returns== | ||
;lRetLen (LONG) - returns | ;lRetLen (LONG) - returns:Length of returned text not including the null terminator. | ||
:Length of returned text not including the null terminator. | |||
==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== | ||
Line 39: | Line 31: | ||
==Example Code== | ==Example Code== | ||
This example shows how to query window text. | This example shows how to query window text. | ||
<pre> | <pre> | ||
#define INCL_WINWINDOWMGR | #define INCL_WINWINDOWMGR | ||
#include < | #include <os2.h> | ||
#define FID_CLIENT 255 | #define FID_CLIENT 255 | ||
Line 64: | Line 55: | ||
WinQueryWindowText(hwndFrame, sizeof(szTitle), szTitle); | WinQueryWindowText(hwndFrame, sizeof(szTitle), szTitle); | ||
</pre> | </pre> | ||
Line 90: | Line 65: | ||
* [[WinSetDlgItemText]] | * [[WinSetDlgItemText]] | ||
* [[WinSetWindowText]] | * [[WinSetWindowText]] | ||
==Related Messages== | ==Related Messages== | ||
* WM_QUERYWINDOWPARAMS | * WM_QUERYWINDOWPARAMS | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 07:15, 7 August 2023
This function copies window text into a buffer.
Syntax
WinQueryWindowText(hwnd, lLength, pun)
Parameters
- hwnd (HWND) - input
- Window handle.
- If hwnd is a frame-window handle, the title-bar window text is copied.
- lLength (LONG) - input
- Length of pun.
- It must be greater than 0.
- pun (PUN) - output
- Window text.
Returns
- lRetLen (LONG) - returns
- Length of returned text not including the null terminator.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
If the window text is longer than (lLength-1) only the first (lLength-1) characters of window text are copied.
If the window is the frame window, the title bar window text is copied.
This function sends a WM_QUERYWINDOWPARAMS message to hwnd.
If this function references the window of another process, pun must be in memory that is shared by both processes, otherwise a memory fault can occur.
Note: Extreme caution must be used if this function is used to access an object window (that is, a window that is descended from HWND_OBJECT). This is because it is very possible that the thread that owns the object window might not be processing it's message queue, and if this is the case, a system halt could occur.
Example Code
This example shows how to query window text.
#define INCL_WINWINDOWMGR #include <os2.h> #define FID_CLIENT 255 HWND hwndFrame; HWND hwndClient; char szTitle[32]; /* This function creates a new window of */ /* class Generic and returns hwnd. */ hwndClient = WinCreateWindow(hwndFrame, "Generic", (PSZ)"My Window", /* No window text */ 0UL, /* No window style */ 0,0,0,0, /* Position and size */ (HWND)NULL, /* No owner */ HWND_TOP, /* On top of siblings */ FID_CLIENT, /* Client window ID */ NULL, /* Control data */ NULL); /* Pres. params */ WinQueryWindowText(hwndFrame, sizeof(szTitle), szTitle);
Related Functions
- WinQueryDlgItemShort
- WinQueryDlgItemText
- WinQueryDlgItemTextLength
- WinQueryWindowTextLength
- WinSetDlgItemShort
- WinSetDlgItemText
- WinSetWindowText
Related Messages
- WM_QUERYWINDOWPARAMS