Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function retrieves the length, in characters, of the specified window's title bar text — if the window has a title bar. If the specified window is a control, the function retrieves the length of the text within the control.

Syntax

int GetWindowTextLength( 
  HWND 
hWnd 
); 

Parameters

hWnd

[in] Handle to the window or control.

Return Value

The length, in characters, of the text indicates success. Under certain conditions, this value may actually be greater than the length of the text. For more information, see the following Remarks section. Zero indicates that the window has no text. To get extended error information, call GetLastError.

Remarks

If the target window is owned by the current process, GetWindowTextLengthcauses a WM_GETTEXTLENGTHmessage to be sent to the specified window or control.

To obtain the exact length of the text, use the WM_GETTEXT, LB_GETTEXT, or CB_GETLBTEXTmessages, or the GetWindowTextfunction.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also