TCustomForm.MakeFullyVisible not working (when form not yet visible / e.g., during start of IDE)
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
The IDE calls TCustomForm.MakeFullyVisible for all its windows while starting up.
This does not work correctly in case of a multi monitor setup (at least on windows, maybe others).
TCustomForm.MakeFullyVisible defers the task of finding the correct Monitor to the Widgetset, which at least on Windows will use an OS function.
But at the time of calling TCustomForm.MakeFullyVisible, the form is not yet visible.
Therefore the bounds of the form are not yet known by the OS.
TWinControl.DoSendBoundsToInterface does not send them
if (Parent = nil) and (not HandleObjectShouldBeVisible) then
That means the OS may return the wrong monitor, the windows is then moved into that wrong monitor.
-----------------
As a work around (and proof of the above being correct) insert one line of code
procedure TCustomForm.MakeFullyVisible(AMonitor: TMonitor; UseWorkarea: Boolean = False);
...
begin
TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height); // insert as 1st line in func
This will force the coordinates being sent, and the windows will be kept in the right monitor, but moved to be fully visible.
Steps to reproduce:
You need to find out which Monitor your OS returns in the above case. Presumingly the Monitor with the coordinates (0,0).
You may need to swap which monitor to use in the below.
- On a 2 Monitor system, start the IDE.
Assuming the monitors to be left/right to each other. E.g A:(0,0, 2559,1439) and B:(2560,0, 5119,1439)
- Move the IDE main bar, so its left and right are well within Monitor B. But its top is slightly out (y=-20)
- Close the IDE, to save the coordinates (save your desktop if needed)
- Open the IDE
The main bar is not fully visible, so it will be moved.
It will be moved into screen A
Actually it will be moved half into screen A... Not sure why. But in any case the IDE believes it should be on Screen A.
With the above fix, it will be moved only the 20 pixel down, and keep its position.
----------------
To make matters more interesting my screens are
A:(0,0, 2559,1439) and B:(2560,150, 4159,1199)
B is smaller, and does not have the same top.
That means the desktop is: 0,0, 4159, 1439. But part of the desktop, on the right side is not on any screen.
(Coordinates below are guessed from what I see)
If the main bar, was at x: 2600 (width: 900), y: 130 (that is -20 relative to the screen).
Then it will be moved to x= 2360, y= 130 (y is kept / x is moved into Screen A, but a lot of the window is still in screen B)
And besides being on the wrong screen, it is not even fully visible, because a big part is still on screen B, but partly above its top.
Mantis conversion info:
- Mantis ID: 34692
- OS: win 10
- OS Build: 10
- Platform: 64bit Intel
- Version: 2.1 (SVN)
- Fixed in version: 2.2
- Fixed in revision: 60521 (#b10aae8c)
- Target version: 2.2