Windows API Guide: GetProfileInt Function


Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long

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

GetWindowTextLength returns the length in characters of a window's text. You can use this function in conjunction with GetWindowText to create a string just long enough to receive the text. However, this function does not include the terminating null character in the window's text in the character count. In some instances, this function might report a larger text length than actually exists; however, it will never report fewer than the actual number of characters. GetWindowTextLength does not work with controls owned by other programs. To get the window text length of these controls, use the WM_GETTEXTLENGTH message instead.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns the number of characters in the window's text, not including the terminating null character.

Visual Basic-Specific Issues

None.

Parameters

hWnd
A handle to the window to retrieve the length of the window text of.

Example

' Display the text displayed in the title bar of window Form1 Dim textlen As Long  ' receives length of text of the window Dim wintext As String  ' receives the text of the window Dim slength As Long  ' receives the length of the returned string ' Find out how many characters are in the window's text. ' Add 1 to compensate for the terminating null. textlen = GetWindowTextLength(Form1.hWnd) + 1 ' Make sufficient room in the buffer. wintext = Space(textlen) ' Retrieve the text of window Form1. slength = GetWindowText(Form1.hWnd, wintext, textlen) ' Remove the empty space from the string, if any. wintext = Left(wintext, slength) ' Display the result. Debug.Print "The title bar of window Form1 is: "; wintext

See Also

GetWindowText, WM_GETTEXTLENGTH

Category

Windows

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: February 12, 2000.
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
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/g/getwindowtextlength.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net