For some applications, it’s important to know, where the taskbar is located. Of course, most users use standard “bottom of the screen” position, but of course, you can place it to the left, rigtht or top of the screen. Here is the method to determine actual position.
Whole procedure is pretty simple. We find coordinates of the taskbar using FindWindow and GetWindowRect functions. And then we compare them with Screen coordinates (area).
procedure TForm1.Button1Click(Sender: TObject); var hTaskbar: HWND; T: TRect; ScrW, ScrH: integer; begin ScrW := Screen.Width; ScrH := Screen.Height; hTaskBar := FindWindow('Shell_TrayWnd', nil); GetWindowRect(hTaskBar, T); if (T.Top > ScrH DIV 2) and (T.Right >= ScrW) then ShowMessage('Bottom of the screen') else if (T.Top < ScrH DIV 2) and (T.Bottom <= ScrW DIV 2) then ShowMessage('Top of the screen') else if (T.left < ScrW DIV 2) and (T.Top <= 0) then ShowMessage('Left side of the screen') else ShowMessage('Right side of the screen'); end;