The 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.
Syntax
BOOL SetWindowText( HWND hWnd,
LPCTSTR lpString
)
Parameters
hWnd
[in] Handle to the window or control whose text is to be changed.
lpString
[in] Pointer to a null-terminated string to be used as the new title or control text.
Return Value
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.
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
The SetWindowText function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters.
Windows 95/98/Me: SetWindowTextW is supported by the Microsoft�0�3 Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
Example:
HWND hwndCombo
int cTxtLen
PSTR pszMem
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDD_ADDCBITEM:
// Get the handle of the combo box and the
// length of the string in the edit control
// of the combo box.
hwndCombo = GetDlgItem(hwndDlg, IDD_COMBO)
cTxtLen = GetWindowTextLength(hwndCombo)
// Allocate memory for the string and copy
// the string into the memory.
pszMem = (PSTR) VirtualAlloc((LPVOID) NULL,
(DWORD) (cTxtLen + 1), MEM_COMMIT,
PAGE_READWRITE)
GetWindowText(hwndCombo, pszMem,
cTxtLen + 1)
// Add the string to the list box of the
// combo box and remove the string from the
// edit control of the combo box.
if (pszMem != NULL)
{
SendDlgItemMessage(hwndDlg, IDD_COMBO,
CB_ADDSTRING, 0,
(DWORD) ((LPSTR) pszMem))
SetWindowText(hwndCombo, (LPSTR) NULL)
}
// Free the memory and return.
VirtualFree(pszMem, 0, MEM_RELEASE)
return TRUE
//
// Process other dialog box commands.
//
}
//
// Process other dialog box messages.
//
}
Function Information
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP
您好,在Windows 10系或扰猜统中,修改任务栏窗口李运名称的衫型方法如下:1、首先,右击任务栏中的窗口,然后选择“属性”;
2、在d出的窗口中,找到“标题”栏,输入您想要修改的窗口名称;
3、点击“确定”按钮,即可完成窗口名称的修改。
此外,您还可以通过右击任务栏中的窗口,然后选择“重命名”来修改窗口名称。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)