Author: Jonas Bilinkevicius
Can anyone tell me how to set and reset the Windows TaskBar AlwaysOnTop property
from within my application?
Answer:
1 procedure TForm1.Button1Click(Sender: TObject);
2 var
3 hw: HWND;
4 begin
5 hw := FindWindow('Shell_TrayWnd', nil);
6 if hw <> 0 then
7 begin
8 if (GetWindowLong(hw, GWL_EXSTYLE) and WS_EX_TOPMOST) <> 0 then
9 begin
10 label1.caption := 'Taskbar is topmost';
11 SetWindowPos(hw, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE);
12 end
13 else
14 begin
15 label1.caption := 'Taskbar is not topmost';
16 SetWindowPos(hw, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE);
17 end;
18 end;
19 end;
|