How to get the position of the Windows Taskbar (Views: 29)
Problem/Question/Abstract: I want to get some desktop settings in variables, like background color etc. But I don't want to use the registry, does anybody know a different way? I also want to know the height of the taskbar, and the position of the taskbar (top of the screen, bottom, left or right). Answer: For the following example put a RadioGroup on your form and give it 5 items: implementation type TTaskBarPosition = (tpHide, tpBottom, tpLeft, tpRight, tpTop); function FindTaskBarPos(aWorkArea: TRect): TTaskBarPosition; begin if aWorkArea.Left <> 0 then begin Result := tpLeft; Exit; end; if aWorkArea.Top <> 0 then begin Result := tpTop; Exit; end; if aWorkArea.Right <> Screen.Width then begin Result := tpRight; Exit; end; if aWorkArea.Bottom <> Screen.Height then begin Result := tpBottom; Exit; end; Result := tpHide; end; procedure TForm1.FormCreate(Sender: TObject); var WorkArea: TRect; begin Color := clBackground; SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkArea, 0); RadioGroup1.ItemIndex := Ord(FindTaskBarPos(WorkArea)); end; end. |