SetWindowText function

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

C++
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

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

SetWindowTextW (Unicode) and SetWindowTextA (ANSI)

See also

Reference GetWindowText WM_SETTEXT Conceptual Windows
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值