yusufmalikul
yusufmalikul

Reputation: 548

How to Change Taskbar Title of Current Running Application?

I have delphi7 code that change application title currently running (other application, not my application).

procedure TForm1.Button1Click(Sender: TObject);
var
 MyHandle: THandle;
begin
 MyHandle:=FindWindow(nil, 'Default Form Caption');
 SetWindowText(MyHandle, 'New Form Caption');
end;

It change the title of the windows form but the taskbar title of that form won't change. How to change the taskbar title ?

Upvotes: 0

Views: 3267

Answers (1)

David Heffernan
David Heffernan

Reputation: 612934

The text displayed in the taskbar is the window text of the window associated with the taskbar button. So SetWindowText will do the job, provided you find the right window.

Often the window you need is the main form's window. But, as seems to be the case here, not always. For instance, older Delphi applications associate the application object's window with the taskbar button, rather than the main form's object. And other frameworks may do similar.

To find the right window, use a tool like Spy++ to study the window hierarchy of the target application. Then use FindWindow or FindWindowEx or similar to find the right window. Then call SetWindowText.

Upvotes: 3

Related Questions