Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.
函数功能: 替换指定窗口的标题栏(如果标题栏存在). 如果指定的窗口是一个控件, 则替换控件的文本. 不过SetWindowText函数不能改变 位于其他程序中的 控件的文本。(那能否改变其他程序中的窗口的标题呢?)
Syntax
BOOL WINAPI SetWindowText( _In_ HWND hWnd, _In_opt_ LPCTSTR lpString );
Parameters
参数
-
hWnd [in]
-
Type: HWND
A handle to the window or control whose text is to be changed.
-
第一个参数:需要改变的窗口或者控件的句柄
lpString [in, optional](可选?)
-
Type: LPCTSTR
The new title or control text.
-
第二个参数:新的标题名或者控件文本
-
-
Return value
-
返回值
Type:
Type: BOOL
If the function succeeds, the return value is nonzero.
如果函数执行成功,返回值为非零。
If the function fails, the return value is zero. To get extended error information, call GetLastError.
如果函数执行失败,返回值为零。。。。。
Remarks
备注
If the target window is owned by the current process, SetWindowText causes a WM_SETTEXT message to be sent to the specified window or control. If the control is a list box control created with the WS_CAPTION style, however, SetWindowText sets the text for the control, not for the list box entries.
如果目标窗口属于当前进程,SetWindowText函数产生一个WM_SETTEXT消息(此消息将发送给指定的窗口或控件)。如果控件是一个WS_CAPTION类型的列表框(list box control), 则SetWindowText函数设置控件的文本,而不是列表框的条目。(不甚明白!)
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
如果需要设置其他进程中控件的文本,直接发送WM_SETTEXT消息即可,而不需要通过函数SetWindowText.。(反正都是通过发送WM_SETTEXT消息来完成设置的,那当前进程能够直接发送消息呢?)
The SetWindowText function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters.
SetWindowText函数不支持tab键(ASCII码为0x09)。Tab键将会以竖线进行显示。
Examples
For an example, see Sending a Message.
Requirements
Minimum supported client | Windows 2000 Professional [desktop apps only] |
---|---|
Minimum supported server | Windows 2000 Server [desktop apps only] |
Header |
|
Library |
|
DLL |
|
Unicode and ANSI names | SetWindowTextW (Unicode) and SetWindowTextA (ANSI) |
See also
-
Reference
GetWindowText
WM_SETTEXT
Conceptual
Windows