(CodeLib-Manager)
Registriert seit: 27. Nov 2008
Ort: Delmenhorst
2.379 Beiträge
|
Re: Größe und Position der Taskbar ermitteln?
9. Okt 2009, 16:43
Gnarf...
"SHAppBarMessage(ABM_GETTASKBARPOS, abd)" liefert die Position der Taskbar, ohne dass man mit FindWindow herumspielen muss. Ein wenig Mathe erledigt dann den Rest...
Delphi-Quellcode:
procedure SetWindowPosition(wnd: HWND);
var
TaskBarRct: TRect;
X: Integer;
Y: Integer;
abd: TAppBarData;
begin
if wnd <> INVALID_HANDLE_VALUE then
begin
abd.cbSize := SizeOf(TAppBarData);
abd.hWnd := wnd;
SHAppBarMessage(ABM_GETTASKBARPOS, abd);
TaskBarRct := abd.rc;
//TaskBar left & top
if (TaskBarRct.TopLeft.X = 0) and (TaskbarRct.TopLeft.Y = 0) then
begin
//left
if TaskBarRct.BottomRight.Y > TaskBarRct.BottomRight.X then
begin
X := TaskBarRct.BottomRight.X + 5;
Y := TaskBarRct.BottomRight.Y - 5 - WindowHeight;
MoveWindow(Wnd, X, Y, WindowWidth, WindowHeight, true);
end
else
//top
begin
X := TaskBarRct.BottomRight.X - 5 - WindowWidth;
Y := TaskBarRct.BottomRight.Y + 5;
MoveWindow(Wnd, X, Y, WindowWidth, WindowHeight, true);
end;
end;
//TaskBar bottom
if (TaskBarRct.TopLeft.X = 0) and (TaskbarRct.TopLeft.Y <> 0) then
begin
X := TaskBarRct.BottomRight.X - 5 - WindowWidth;
Y := TaskbarRct.TopLeft.Y - 5 - WindowHeight;
MoveWindow(Wnd, X, Y, WindowWidth, WindowHeight, true);
end;
//Taskbar right
if (TaskBarRct.TopLeft.X <> 0) and (TaskbarRct.TopLeft.Y = 0) then
begin
X := TaskBarRct.TopLeft.X - 5 - WindowWidth;
Y := TaskBarRct.BottomRight.Y - 5 - WindowHeight;
MoveWindow(Wnd, X, Y, WindowWidth, WindowHeight, true);
end;
end;
end;
米斯蘭迪爾 "In einer Zeit universellen Betruges wird das Aussprechen der Wahrheit zu einem revolutionären Akt." -- 1984, George Orwell
|
|
Zitat
|