Raymond Chen posted this article yesterday -> https://devblogs.microsoft.com/oldnewth ... /?p=107318
From what I gather, he's saying it's best to use app window sizes (and gadgets for PureBasic) in multiples of 4 or 8 pixels, so they scale better at different DPI settings? Am I reading that right? If so, I might have to go and re-do my interfaces. Dang it.
(And if that's right, the PureBasic visual designer should also be changed to default to 8 pixels for the grid and gadget sizes/positions).
Windows sizes and DPI
Re: Windows sizes and DPI
Yes, I hadn't thought of that but it seems logical given the scaling rates used.
It can be seen easily with:
However, to be consistent, #PB_Gadget_RequiredSize (WM_GETMINMAXINFO) should also be in base 4 or 8 which is not the case
It can be seen easily with:
Code: Select all
Debug #CRLF$ + "----- Length Scaled: 1 - 1.25 - 1.5 - 1.75 - 2 - 2.5 - 3 - 3.5 - 4 - 4.5 - 5"
For x = 1 To 24
Debug Str(x) + " - " + Str(x*1.25) + " - " + Str(x*1.5) + " - " + Str(x*1.75) + " - " + Str(x*2) + " - " + Str(x*2.5) + " - " + Str(x*3) + " - " + Str(x*3.5) + " - " + Str(x*4) + " - " + Str(x*4.5) + " - " + Str(x*5)
Debug Str(x) + " - " + StrF(x*1.25) + " - " + StrF(x*1.5) + " - " + StrF(x*1.75) + " - " + StrF(x*2) + " - " + StrF(x*2.5) + " - " + StrF(x*3) + " - " + StrF(x*3.5) + " - " + StrF(x*4) + " - " + StrF(x*4.5) + " - " + StrF(x*5)
Debug "-----"
Next
However, to be consistent, #PB_Gadget_RequiredSize (WM_GETMINMAXINFO) should also be in base 4 or 8 which is not the case
Code: Select all
Macro ModelHeight(_Model_)
ReqHeight = ReqHeightModel(_Model_)
Debug _Model_ + ": " + Str(ReqHeight) + " / 4 = " + StrF(ReqHeight/4)
EndMacro
Procedure ReqHeightModel(Model.s)
Protected TempGadget.i, ReqHeight.i, DummyText.s = "ABC123"
Select Model
Case "ButtonGadget"
TempGadget = ButtonGadget (#PB_Any, 0, 0, 25, 25, DummyText)
Case "ButtonImageGadget"
TempGadget = ButtonImageGadget(#PB_Any, 0, 0, 25, 25, 0)
Case "CalendarGadget"
TempGadget = CalendarGadget (#PB_Any, 0, 0, 25, 25)
Case "CheckBoxGadget"
TempGadget = CheckBoxGadget (#PB_Any, 0, 0, 25, 25, DummyText)
Case "ComboBoxGadget"
TempGadget = ComboBoxGadget (#PB_Any, 0, 0, 25, 25, #PB_ComboBox_Editable) : SetGadgetText(TempGadget, DummyText)
Case "DateGadget"
TempGadget = DateGadget (#PB_Any, 0, 0, 25, 25)
Case "HyperLinkGadget"
TempGadget = HyperLinkGadget (#PB_Any, 0, 0, 25, 25,DummyText, $FF0000)
Case "ImageGadget"
TempGadget = ImageGadget (#PB_Any, 0, 0, 25, 25, 0)
Case "IPAddressGadget"
TempGadget = IPAddressGadget (#PB_Any, 0, 0, 25, 25)
Case "OptionGadget"
TempGadget = OptionGadget (#PB_Any, 0, 0, 25, 25, DummyText)
Case "ScrollBarGadget"
TempGadget = ScrollBarGadget (#PB_Any, 0, 0, 25, 25, 0, 100, 10)
Case "SpinGadget"
TempGadget = SpinGadget (#PB_Any, 0, 0, 25, 25, 0, 100, #PB_Spin_ReadOnly)
Case "StringGadget"
TempGadget = StringGadget (#PB_Any, 0, 0, 25, 25, DummyText)
Case "TextGadget"
TempGadget = TextGadget (#PB_Any, 0, 0, 25, 25, DummyText)
EndSelect
If IsGadget(TempGadget)
ReqHeight = GadgetHeight(TempGadget, #PB_Gadget_RequiredSize)
;Debug Model + " : " + Str(ReqHeight)
FreeGadget(TempGadget)
EndIf
ProcedureReturn ReqHeight
EndProcedure
If OpenWindow(0,0,0,0,0,"",#PB_Window_BorderLess)
ModelHeight("ButtonGadget")
ModelHeight("ButtonGadget")
ModelHeight("ButtonImageGadget")
ModelHeight("CalendarGadget")
ModelHeight("CheckBoxGadget")
ModelHeight("ComboBoxGadget")
ModelHeight("DateGadget")
ModelHeight("HyperLinkGadget")
ModelHeight("ImageGadget")
ModelHeight("IPAddressGadget")
ModelHeight("OptionGadget")
ModelHeight("ScrollBarGadget")
ModelHeight("SpinGadget")
ModelHeight("StringGadget")
ModelHeight("TextGadget")
CloseWindow(0)
EndIf
Re: Windows sizes and DPI
Ha, what a luck.
I've always done that with multiples of 8 ....
I have actually done everything right for years....
Sorry, no gloating here.
I've always done that with multiples of 8 ....
I have actually done everything right for years....
Sorry, no gloating here.

Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Re: Windows sizes and DPI
You're funny, Axolotl. Hehe.
Re: Windows sizes and DPI
You can use Constants for gadget type
- #PB_GadgetType_Button, etc
- #PB_GadgetType_Button, etc
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Windows sizes and DPI
Yep, it would be better for the select case indeed but at some point I have to write it, for the function ButtonGadget() or here for the model name in Debug.mk-soft wrote: Wed Oct 26, 2022 1:27 pm You can use Constants for gadget type
- #PB_GadgetType_Button, etc
Re: Windows sizes and DPI
I never even thought about that before. It makes sense maybe macros would help wrap the window and gadget commands in macros so the dimensions are aligned 8 or 4.
That way you won't need to do anything to existing code.
That way you won't need to do anything to existing code.
Re: Windows sizes and DPI
I forgot to answer this from the other day, here's an example of what I said using marcos
Code: Select all
Macro _OpenWindow(window,x,y,innerWidth,InnerHeight,Title,flags=0,parentid=0)
OpenWindow(window,x-(x&7),y-(y&7),innerWidth - (innerwidth & 7) ,InnerHeight - (innerheight & 7),Title,flags,parentid)
EndMacro
Macro _ResizeWindow(window,x,y,width,height)
ResizeWindow(window,x-(x&7),y-(y&7),Width - (width & 7) ,Height - (height & 7))
EndMacro
Procedure Resize()
Protected x,y,w,h
window = EventWindow()
x = WindowX(window)
y = WindowY(window)
w = WindowWidth(window)
h = WindowHeight(window)
_ResizeWindow(window,x,y,w,h)
Debug GetWindowTitle(window) + " width : " + WindowWidth(window) + " height : " + WindowHeight(window)
EndProcedure
#Style = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered
_OpenWindow(0,0,0,802,603,"test 0", #Style)
BindEvent(#PB_Event_SizeWindow, @Resize(),0)
Repeat
Ev = WaitWindowEvent()
Until Ev = #PB_Event_CloseWindow