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.
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)
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 targetWin32
If desiredWidth = 0 Then
desiredWidth = win.Width
End If
If desiredHeight = 0 Then
desiredHeight = win.height
End If
// InitMetrics
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
Else
borderWidth = gwin32edgeWidth
borderHeight = gwin32EdgeHeight
End If
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)
#Else
win.Top = desiredTop
win.Left = desiredLeft
win.Width = desiredWidth
win.Height = desiredHeight #EndIf
End Sub
[/code]