SetWindowText

2.x

  void SetWindowText(hwnd, lpsz)    
  HWND hwnd; /* handle of window, */  
  LPCSTR lpsz; /* address of string, */  

The SetWindowText function sets the given window's title to the specified text.

Parameters

hwnd

Identifies the window or control whose text is to be set.

lpsz

Points to a null-terminated string to be used as the new title or control text.

Return Value

This function does not return a value.

Comments

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

If the window specified by the hwnd parameter is a control, the text within the control is set. If the specified window is a list-box control created with WS_CAPTION style, however, SetWindowText will set the caption for the control, not for the list-box entries.

Example

The following example sets a window title:

char szBuf[64];
char szFileName[64];

wsprintf((LPSTR) szBuf, "PrntFile - %s", (LPSTR) szFileName);
SetWindowText(hwnd, (LPSTR) szBuf);

See Also

GetWindowText