In a production software, I use: Window.Bounds the way the docs shows:
Dim myBounds As New Realbasic.Rect
myBounds.Left = 100
myBounds.Top = 100
myBounds.Height = Self.Height
myBounds.Width = Self.Width
Self.Bounds = myBounds
In fact, at close time, I store to disk a bunch of data includint these. And at open time, I restore them from the disk.
This works fine (very fine, nicely, etc.) on my developer machine (MacBook Pro 13"), but I get phone calls, regularly) telling me the window does not opens (in fact the window opend outside of the visible screen).
At first, on a MacBook 15", but the user have an external hard disk and I attribute that “bug” to this particularity (even if on macOS, this is just impossible to keep a window outside of the screen).
Now, he gets that on a Windows 7 (recently installed) machine. This morning, he gets for x,y values
32000,32000 (or was it -32000, -32000 ?) ! The solution is simple: close the window, delete the preferences file and re-open the window. This cancels the use of this (nice) feature that cost me so many times to implement. A feature I really love !
Any idea on how this can arise ?
Just a shot in the dark.
Maybe he last closed (and saved the data) when he was using multiple screens and the app was not in the main screen, and then opened it on a single screen setup (or after he removed the additional screen/s).
Thanks for trying.
Good bet.
On macOS, this is not possible: the OS moves the window if it have a X,Y value (or both) that will lead to display the window outside of the display area.
On Windows, it is possible, but in that case (the client case), officially, they use only one Monitor connected to the PC tower.
I installed (my software) Windows 7 two weeks ago, and it is used since the start of this week (they relocated their business last week).
However, I will test (check) these this afternoon.
I will also check at preferences load time the X,Y values and modify them accordingly of the connected # of monitors and the currently used monitor size (in pixels, of course).
BTW: no Retina nor HiDPI are involved.
Last but not least: I moved to use Realbasic.Rect
because I already had this trouble earlier.
–
Same player shoot again.
I was driving nearly two hours ago and get a crazy idea:
What if Realbasic.Rect
have a bug ?
So, in my Prefs file, I set a minus value for left (large enough for it to not display the window on screen (on my actual unique screen).
Ive done that, fired the application, ask to display the window and the window is displayed OUTSIDE of the unique monitor (just like Windows / just like if there is a connected Monitor on the left of the built in).
Tested with Xojo 2015r1 AND 2017r1.1.
A while back I nearly lost my hair till I figured it out. When a user displays the desktop on windows by clicking the little button in the lower right, or pressing win+d, all windows are minimized but differently than by clicking the minimize button. It sets the top and left of windows to -32000.
In my app I also store position and window size, in the resize and move events. I simply added a check and if self.top = -32000 then return.
Or if I don’t want negative numbers I save the values like this:
dim l, t as integer
l = max(0, self.left)
h = Max(0, self.top)
I don’t know about Windows, but on Mac window positioning with negative numbers is possible on secondary screens.
on secondary screens
when that monito is located to the left of the other monitor.
In fact, I will so something like:
Left (or X)
If Saved_X < 0 Then Saved_X = 0
If Saved_X > Screen(0).Width Then Saved_X = 0
Top (or Y)
If Saved_Y < 0 Then Saved_Y = 50
If Saved_Y > Screen(0).Height Then Saved_Y = 50
Left = 0
: will be displayed at the leftmost of the current screen.
Top = 50
: will be displayed a bit below MenuBar of the current screen.
While waiting for:
the bug will be removed,
I get money to buy a correct version
Thank you all.