Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
Platforms
- Windows 95: Supported.
- Windows 98: Supported.
- Windows NT: Requires Windows NT 3.1 or later.
- Windows 2000: Supported.
- Windows CE: Requires Windows CE 1.0 or later.
Description & Usage
Send the WM_GETTEXTLENGTH message to a window to discover the number of characters in that window's text. This character count does not include the terminating null character. In some cases, this message will report a larger number of characters than what actually exists; however, the count obtained by this message will always be no less than the actual number of characters. The WM_GETTEXTLENGTH message is handled by the target window's default window procedure.
Return Value
The message returns the number of characters in the target window's text, not including the terminating null.
Visual Basic-Specific Issues
When using SendMessage to send the WM_GETTEXTLENGTH message, both the wParam and lParam parameters must be set using the expression ByVal CLng(0).
Parameters
- wParam
- Not used -- set to 0.
- lParam
- Not used -- set to 0.
Constant Definitions
Const WM_GETTEXTLENGTH = &HE
Example
' This code is licensed according to the terms and conditions listed here. ' Display the title bar text of window Form1 by sending the ' appropriate messages to it. Dim wintext As String ' receives the copied text from the target window Dim slength As Long ' length of the window text Dim retval As Long ' return value of message ' First, determine how much space is necessary for the buffer. ' (1 is added for the terminating null character.) slength = SendMessage(Form1.hWnd, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1 ' Make enough room in the buffer to receive the text. wintext = Space(slength) ' Copy the target window's text into the buffer. retval = SendMessage(Form1.hWnd, WM_GETTEXT, ByVal slength, ByVal wintext) ' Remove the terminating null and extra space from the buffer. wintext = Left(wintext, retval) ' Display the result. Debug.Print "Form1's title bar text is: "; wintext
See Also
GetWindowTextLength, WM_GETTEXT
Category
Windows
Back to the Message list. Back to the Reference section.
Last Modified: January 27, 2000 This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000 Go back to the Windows API Guide home page. E-mail: vbapi@vbapi.com Send Encrypted E-Mail This page is at http://www.vbapi.com/ref/w/wm_gettextlength.html