Mega Code Archive

 
Categories / Delphi / API
 

Getting the size of the desktop

Question: How do I find the size of the Desktop minus the taskbar? Answer: Call the Windows API function SystemParametersInfo() passing the SPI_GETWORKAREA parameter along with the address of the rectangle structure to receive the coordinates. Example: procedure TForm1.Button1Click(Sender: TObject); var r : TRect; begin SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0); Memo1.Lines.Add(IntToStr(r.Top)); Memo1.Lines.Add(IntToStr(r.Left)); Memo1.Lines.Add(IntToStr(r.Bottom)); Memo1.Lines.Add(IntToStr(r.Right)); end;