GetWindowText

  int GetWindowText(hwnd, lpString, nMaxCount)    
  HWND hwnd; /* handle of window */
  LPTSTR lpString; /* address of buffer for text */
  int nMaxCount; /* maximum number of characters to copy */

This function copies the given window's caption title (if it has one) into the buffer pointed to by the lpString parameter. If the hwnd parameter identifies a control, the GetWindowText function copies the text within the control instead of copying the caption.

Parameters

hwnd

Identifies the window or control whose caption or text is to be copied.

lpString

Points to the buffer that is to receive the copied string.

nMaxCount

Specifies the maximum number of characters to be copied to the buffer. If the string is longer than the number of characters specified in the nMaxCount parameter, it is truncated.

Return Value

The return value specifies the length (in characters) of the copied string, not including the null-terminating character. It is zero if the window has no caption or if the caption is empty.

Comments

This function causes a WM_GETTEXT message to be sent to the given window or control.

The GetWindowText function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set).

See Also

SetWindowText, GetWindowTextLength