View Issue Details

IDProjectCategoryView StatusLast Update
0034692LazarusLCLpublic2019-02-26 20:41
ReporterMartin FriebeAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platform64bit IntelOSwin 10OS Version10
Product Version2.1 (SVN)Product Build 
Target Version2.2Fixed in Version2.2 
Summary0034692: TCustomForm.MakeFullyVisible not working (when form not yet visible / e.g., during start of IDE)
DescriptionThe 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 ReproduceYou 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.
TagsNo tags attached.
Fixed in Revision60521
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Alexey Tor.

2019-02-26 20:41

reporter   ~0114472

Good analysys. Thanks.

Issue History

Date Modified Username Field Change
2018-12-12 12:26 Martin Friebe New Issue
2019-02-26 20:35 Martin Friebe Fixed in Revision => 60521
2019-02-26 20:35 Martin Friebe Status new => resolved
2019-02-26 20:35 Martin Friebe Fixed in Version => 2.2
2019-02-26 20:35 Martin Friebe Resolution open => fixed
2019-02-26 20:35 Martin Friebe Assigned To => Martin Friebe
2019-02-26 20:35 Martin Friebe Target Version => 2.2
2019-02-26 20:41 Alexey Tor. Note Added: 0114472