Window scaling issue
Posted: Thu Nov 20, 2025 9:46 am
If I open a window on a screen with display scale greater than 100% then I have found that the InnerWidth and InnerHeight need to be the scaled dimensions. For example, my secondary monitor is 3840x2160, but the display scale is 150% so for a full screen display the window's InnerWidth needs to be 2560 and the InnerHeight 1440.
That all works fine, but if I want to display two borderless windows side by side on that screen, and so assign an InnerWidth of 1280 then PB ignores the 150% scaling and shows windows smaller.
I hope that makes sense. If you have a secondary monitor with a display scale greater than 100% then the following program will reproduce the problem:
Set nScalingPercentage to the display scale of the Windows display (as shown under Windows / Display).
This program should display Window1 on your main screen, then Window2 and Window3 side by side on your secondary screen. WIndow2 is yellow and Window3 is green.
Window2 and Window3 should both be the full height of the secondary display, but with the above program those windows will not be full height of the screen, nor the required width.
There are two ways in this code to fix the problem, but neither of these solutions suit my requirements. One way to 'fix' the problem is to comment out the nFlags setting, so that Window2 and Window3 are NOT borderless.
The second way to fix the problem is to comment out the creation of Window1.
I encountered this issue when using PB 6.20 but the problem still exists in PB 6.30 beta 4.
That all works fine, but if I want to display two borderless windows side by side on that screen, and so assign an InnerWidth of 1280 then PB ignores the 150% scaling and shows windows smaller.
I hope that makes sense. If you have a secondary monitor with a display scale greater than 100% then the following program will reproduce the problem:
Code: Select all
EnableExplicit
Global nDesktops, nWindow1, nWindow2, nWindow3, nFlags
Global nLeft, nTop, nWidth, nHeight
Global nScalingPercentage = 150 ; set this to the display scale of Desktop 1
nDesktops = ExamineDesktops()
nLeft = DesktopX(1)
nTop = DesktopY(1)
nWidth = (DesktopWidth(1) * 100 / nScalingPercentage) / 2
nHeight = DesktopHeight(1) * 100 / nScalingPercentage
nWindow1 = OpenWindow(#PB_Any, 0, 0, 792, 560, "Window Scaling Issue")
nFlags = #PB_Window_BorderLess
nWindow2 = OpenWindow(#PB_Any, nLeft, nTop, nWidth, nHeight, "", nFlags)
SetWindowColor(nWindow2, #Yellow)
nWindow3 = OpenWindow(#PB_Any, (nLeft+nWidth), nTop, nWidth, nHeight, "", nFlags)
SetWindowColor(nWindow3, #Green)
MessageRequester("Test", "End of test")
This program should display Window1 on your main screen, then Window2 and Window3 side by side on your secondary screen. WIndow2 is yellow and Window3 is green.
Window2 and Window3 should both be the full height of the secondary display, but with the above program those windows will not be full height of the screen, nor the required width.
There are two ways in this code to fix the problem, but neither of these solutions suit my requirements. One way to 'fix' the problem is to comment out the nFlags setting, so that Window2 and Window3 are NOT borderless.
The second way to fix the problem is to comment out the creation of Window1.
I encountered this issue when using PB 6.20 but the problem still exists in PB 6.30 beta 4.