用delphi 如何修改其他程序的窗口标题

用delphi 如何修改其他程序的窗口标题,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述此燃逗:

用delphi 如何修改其他程序的窗口标题,请大侠们指点下。谢谢

分不过,就25分了,望段晌见谅

解析:

使用API函数 setWIndowtext

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® 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 bo box and the

length of the string in the edit control

of the bo 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

bo box and remove the string from the

edit control of the bo 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 mands.

}

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

delphi 编团氏枯译的塌洞软件,其窗口显核和示在任务栏的标题,通常可以通过以下方法修改:

在 IDE 菜单里,Project ->Options ->Application ->Title


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12335893.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存