GetWindowText

2.x

  int GetWindowText(hwnd, lpsz, cbMax)    
  HWND hwnd; /* handle of window, */  
  LPSTR lpsz; /* address of buffer for text */
  int cbMax; /* maximum number of bytes to copy */

The GetWindowText function copies text of the given window's title bar (if it has one) into a buffer. If the given window is a control, the text within the control is copied.

Parameters

hwnd

Identifies the window or control containing the title bar or text.

lpsz

Points to a buffer that will receive the title bar or text.

cbMax

Specifies the maximum number of characters to copy to the buffer. The title bar or text is truncated if it is longer than the number of characters specified in cbMax.

Return Value

The return value specifies the length, in bytes, of the copied string, not including the terminating null character. It is zero if the window has no title bar, the title bar is empty, or the hwnd parameter is invalid.

Comments

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

See Also

GetWindowTextLength