Hello, and good morning,
I have a feature request and my solution for multimonitor users, hope that i selected the right sub forum.
I'm using a multi monitor system under Linux ( Kubuntu Karmic 9.10 ) 32 Bit, and the actual SVN Lazarus version.
If i set the position value of the TForm1 to "poScreenCenter" i unhappily do not get the solution i want to.
poScreenCenter in my oppinion means centered on the monitor in which i am currently working, and this monitor is the one in which my mouse is lokated.
poScreenCenter in the aktual Lazarus version means centered on Monitor 0. So i wrote the following code, witch could make the "poScreenCenter" as i expected it ( Working only when the Position value is set to "poDesigned" )
Function PointInRect(P: TPoint; R: TRect): boolean;
Var
t: Integer;
Begin
If r.left > r.right Then Begin
t := r.left;
r.left := r.right;
r.right := t;
End;
If r.top > r.bottom Then Begin
t := r.Bottom;
r.bottom := r.top;
r.top := t;
End;
result := (r.left <= p.x) And (r.right >= p.x) And
(r.top <= p.y) And (r.bottom >= p.y);
End;
Procedure TForm1.FormCreate(Sender: TObject);
Var
i: Integer;
r: Trect;
Begin
If screen.MonitorCount <> 1 Then Begin
For i := 0 To screen.MonitorCount - 1 Do Begin
r := screen.Monitors[i].BoundsRect;
If PointInRect(Mouse.CursorPos, r) Then Begin
left := (screen.Monitors[i].width - form1.width) Div 2 + screen.Monitors[i].BoundsRect.left;
top := (screen.Monitors[i].height - form1.height) Div 2 + screen.Monitors[i].BoundsRect.top;
break;
End;
End;
End
Else Begin
left := (screen.width - form1.width) Div 2;
top := (screen.height - form1.height) Div 2;
End;
..
I found out that this solution don't work under Win32, because there is some Problems with the screen.Monitors, so my solution maybe is not the best one.
But i hope that some of you find a way to do the same under Windows, and integrate it in the LCL.
Corpsman