Author: Jonas Bilinkevicius
How to paint into another windows' caption bar
Answer:
If you can get a handle to a Windows object, generally if it supports a WM_SETTEXT
message (most windows do), then you can change the caption. The example below does
just that:
1 2 procedure Form1.Button1Click(Sender: TObject);
3 begin4 WinExec('notepad.exe', SW_SHOWNORMAL);
5 end;
6 7 procedure Form1.Button2Click(Sender: TObject);
8 var9 hChild: HWND;
10 strNewTitle: string;
11 begin12 hChild := FindWindow(nil, 'Untitled - Notepad');
13 if (hChild <> NULL) then14 begin15 strNewTitle := ' Funny name ';
16 SendMessage(hChild, WM_SETTEXT, 0, LPARAM(PChar(strNewTitle)));
17 end;
18 end;
Note that this was written in D5 and the FindWindow(...) function can be a little ornery in some instances (like case sensitivity and precise text makeup, see example).