I have a problem with the positioning of my document window in a MDI window in the following conditions :
- HiDPI is ON
- 2 monitors (not tested with more)
- the MDI window is in the 2d monitor
- this 2d monitor is on the left or below the 1st (no problem of on the right or above)
I use RB2019r1.1 in Windows 10. The monitors have the same scale factor, same resolution (1920x1080).
Setting the left property to the window seems to have no effect or is not set correctly.
Example : I set myWindow.Left = 7 , but myWindow.Left become 1920
If I use a negative number, the left property is correctly set. But the left border of my window is outside the screen then and it’s not what I want. As soon as the number is >= 0 the but myWindow.Left is not se t correctly.
Just to test, I’ve tried to set a number bigger than 1920 but the result was unsuccessful.
Note : in a MDI window, the document window top/left property is local to the MDI.
Has someone a workaround for this ?
Your second window must be on the right of Screen(0).
As a result,
screen(1).Left = screen(0).width + 1
There you have the 1920.
I don’t understand, though, why the window would be relative to Screen(1) instead of being relative to the MDI.
You say increasing the value from 1920 to something else is inconclusive. What happens if you try 2120 ?
Likewise, have you tried to set Left to 107 ?
If I set self.Left = 2120, the window is positioned to 1328 in the MDI (and I get self.Left = 1328)
If I set self.Left = 107, the window is positioned to 1328 too (and I get self.Left = 1328)
If I set self.Bounds.Left = 1920, the window.Left = 1328 too (and I get self.Bounds.Left = 3240)
If I set self.Bounds.Left = -1, the window.Left = -1 (and I get self.Bounds.Left = 1911)
François says the MDI (second screen) isn’t at the right side:
So I’m not sure what you’re saying (sorry)
Looks terribly much like a bug. But is it a Windows bug or a Xojo one is the question.
At any rate, even Microsoft has been trying to discourage use of MDI for over a decade.
It may be time to do away with it.
It’s a bug in Xojo. Sorry my mistake about relative placement of the 2d monitor : The bug is when the 2d monitor is at right or below the 1st.
The workaround is to use declare. This is my code :
[code]Public Sub PlaceChildWindowAtWin32(win As Window, desiredTop As Integer, desiredLeft As Integer, desiredWidth As Integer = 0, desiredHeight As Integer = 0)
// Note…: Place a document child Window in its MDIWindow
// Workaround bug Xojo 2019R1.1 when
// - the window has a document type frame,
// - MDIWindow is on a 2d monitor
// - this 2d monitor is at right or below the 1st
If desiredWidth = 0 Then
desiredWidth = win.Width
If desiredHeight = 0 Then
desiredHeight = win.height
Declare Function GetSystemMetrics Lib "user32" (nIndex As Integer) As Integer
Const SM_CYCAPTION = 4
Dim gWin32TitleBarHeight As Integer = GetSystemMetrics( SM_CYCAPTION )
Const SM_CXFRAME = 32
Const SM_CYFRAME = 33
Dim gWin32BorderWidth As Integer = GetSystemMetrics( SM_CXFRAME )
Dim gWin32BorderHeight As Integer = GetSystemMetrics( SM_CYFRAME )
Const SM_CXEDGE = 45
Const SM_CYEDGE = 46
Dim gWin32EdgeWidth As Integer = GetSystemMetrics( SM_CXEDGE )
Dim gWin32EdgeHeight As Integer = GetSystemMetrics( SM_CYEDGE )
Dim x, y, w, h, borderWidth, borderHeight As Integer
If win.resizeable Then
borderWidth = gWin32BorderWidth
borderHeight = gwin32borderHeight
borderWidth = gwin32edgeWidth
borderHeight = gwin32EdgeHeight
Dim scale As Double = win.scaleFactor
x = (desiredLeft * scale) - borderWidth
y = (desiredTop * scale) - (gWin32TitleBarHeight + borderHeight)
w = (desiredWidth * scale) + (borderWidth * 2)
h = (desiredHeight * scale) + gWin32TitleBarHeight + (borderHeight * 2)
Declare Function MoveWindow Lib "User32" (hWnd As Integer, x As Int32, y As Int32, nWidth As Int32, nHeight As Int32, bRepaint As Boolean) As Boolean
Call MoveWindow(win.Handle, x, y, w, h, True)
win.Top = desiredTop
win.Left = desiredLeft
win.Width = desiredWidth
win.Height = desiredHeight