Определить позицию панели задач 2
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
{With FindWindow, GetWindowRect }
type
TTaskBarPos = (_TOP, _BOTTOM, _LEFT, _RIGHT, _NONE);
function GetTaskBarPos: TTaskBarPos;
var
hTaskbar: HWND;
T: TRect;
scrW, scrH: integer;
begin
hTaskBar := FindWindow('Shell_TrayWnd', nil);
if hTaskbar <> 0 then
begin
GetWindowRect(hTaskBar, T);
ScrW := Screen.Width;
ScrH := Screen.Height;
if (T.Top > scrH div 2) and (T.Right >= scrW) then
Result := _BOTTOM
else if (T.Top < scrH div 2) and (T.Bottom <= scrW div 2) then
Result := _TOP
else if (T.Left < scrW div 2) and (T.Top <= 0) then
Result := _LEFT
else // the last "if" is not really needed
if T.Left >= ScrW div 2 then
Result := _RIGHT;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
TaskBarPos: TTaskBarPos;
begin
TaskBarPos := GetTaskBarPos;
case TaskBarPos of
_LEFT: ShowMessage('Left Position');
_TOP: ShowMessage('Top Position');
_RIGHT: ShowMessage('Right Position');
_BOTTOM: ShowMessage('Bottom Position');
end;
end;
|