From f08de69e4e4ff4d565fe3dfdf3ea239c62dfc8a5 Mon Sep 17 00:00:00 2001 From: zoran-vucenovic Date: Sun, 10 Mar 2013 16:02:31 +0000 Subject: [PATCH] When TMonitor.WorkareaRect is not implemented, use TMonitor.BoundsRect git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2697 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/ZVDateTimeCtrls/trunk/zvdatetimepicker.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/ZVDateTimeCtrls/trunk/zvdatetimepicker.pas b/components/ZVDateTimeCtrls/trunk/zvdatetimepicker.pas index 236800118..1fcebccaa 100644 --- a/components/ZVDateTimeCtrls/trunk/zvdatetimepicker.pas +++ b/components/ZVDateTimeCtrls/trunk/zvdatetimepicker.pas @@ -550,6 +550,7 @@ end; procedure TDTCalendarForm.AdjustCalendarFormScreenPosition; var + M: TMonitor; R: TRect; P: TPoint; H, W: Integer; @@ -558,8 +559,14 @@ begin W := Width; P := DTPicker.ControlToScreen(Point(0, DTPicker.Height)); + M := Screen.MonitorFromWindow(DTPicker.Handle); - R := Screen.MonitorFromWindow(DTPicker.Handle).WorkareaRect; + R := M.WorkareaRect; + // WorkareaRect sometimes is not implemented (gtk2?). Depends on widgetset + // and window manager or something like that. Then it returns (0,0,0,0) and + // the best we can do is use BoundsRect instead: + if (R.Right <= R.Left) or (R.Bottom <= R.Top) then + R := M.BoundsRect; if P.y > R.Bottom - H then P.y := P.y - H - DTPicker.Height;