WinQueryDlgItemTextLength: Difference between revisions
Appearance
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..." |
|||
(2 intermediate revisions by 2 users 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. | ||
WinQueryDlgItemTextLength(hwndDlg, idItem) | ==Syntax== | ||
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 < | #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); | |||
/* now we know the buffer size needed. */ | |||
DosAllocMem((PPVOID)szTemp, | |||
(ULONG)length, | |||
PAG_READ | | |||
PAG_WRITE | | |||
PAG_COMMIT); | |||
WinQueryDlgItemText(hwndDlg, | |||
DosAllocMem((PPVOID)szTemp, | DID_MSGEDIT, | ||
sizeof(szTemp), | |||
(PSZ)szTemp); | |||
/* . */ | /* . */ | ||
/* . */ | /* . */ | ||
} | } | ||
</pre> | </pre> | ||
==Related Functions== | |||
* [[WinQueryDlgItemShort]] | |||
* [[WinQueryDlgItemText]] | |||
* [[WinQueryWindowText]] | |||
* [[WinQueryWindowTextLength]] | |||
* [[WinSetDlgItemShort]] | |||
* [[WinSetDlgItemText]] | |||
* [[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); /* . */ /* . */ }