Adapt the windows and gadgets quite well with the DPI-Aware option.
Also the image will be adjusted with the modules
Code: Select all
;-TOP
IncludeFile "Modul_ScaleGadgets.pb"
UseModule ScaleGadgets
SetScale(DesktopResolutionX())
...
Code: Select all
;-TOP
IncludeFile "Modul_ScaleGadgets.pb"
UseModule ScaleGadgets
SetScale(DesktopResolutionX())
...
As I just showed in my previous post, that "multiplatform approach" does not work on Windows with PB versions prior to 5.70. And I suppose nobody actually has tested it on the two other platforms ...chi wrote:DPI-Awareness is only available on Windows right now... So this is a multi-platform approachLittle John wrote:Well ... what is the advantage of that code?
This is not actiually surprising, since on Linux (as well as on Mac OS) PureBasic is not aware of DPI settings.1.0
1.0
You can't hard-code a value of PPI like that... it changes depending on your PC's setup! That's why I calculate it at runtime with GetDeviceCaps_() in my first post of this thread.chi wrote:ppi = 96
Excuse the short offtopic, but I can't enable this option in the process explorer at all.bbanelli wrote:...
I think there's more to it. Process Explorer states application as DPI unaware, primarily because you didn't use SetProcessDpiAwareness().
But in effect that is what you have done because of your use of the following :Dude wrote:You can't hard-code a value of PPI like that... it changes depending on your PC's setup! That's why I calculate it at runtime with GetDeviceCaps_() in my first post of this thread.chi wrote:ppi = 96
Code: Select all
x=10*dpi
w=155*dpi
h=20*dpi
The "/100" in my tip does not refer to "100 DPI", but rather "/100%" of DPI; so my gadget scalings are based on a percentage of the current system DPI setting.srod wrote:your code suggests 100dpi, but I suspect you actually used 96DPI as the 'base'
Code: Select all
Global dpi.d=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)/300
Code: Select all
DPIX.d = 1.0
DPIY.d = 1.0
If StartVectorDrawing(CanvasVectorOutput(#Canvas))
DPIY = VectorResolutionY() / 96
DPIX = VectorResolutionX() / 96
StopVectorDrawing()
EndIf
True, but since I code on the standard default minimum DPI size (96 DPI), then my tip will always work because it can only ever scale up and not down, ie. no matter what DPI the user has set their PC too. You can't set a Windows PC DPI to be less than 96 DPI at all, so there's no problem (unless I've overlooked something).srod wrote:Had you originally calculated these values on a system running at 300 DPI (say) then this snippet of yours would produce erroneous results even at 300 DPI since you would then be calculating a scale factor of 3!
Code: Select all
Global dpi.d=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)/300
Correct. And that's exactly what the PureBasics form designer unfortunately doesn't do. On all systems <> 96 dpi you cannot use it, because the resulting DPI aware EXEs are scaled wrong even on the machine where the form was designed.srod wrote:...
For anyone who is laying out a UI which will automatically rescale for use on other systems then they need to take into account the DPI in force at the time they designed the UI...
I would say yes, PE must use GetProcessDpiAwareness() at minimum, which is available only from Win 8.1.kurzer wrote: Excuse the short offtopic, but I can't enable this option in the process explorer at all.
I have Windows 7 x64 running here. Is this the reason that this column option is disabled in process explorer?
I just tested what you said, and you're absolutely correct! That is, I set my PC to 125% DPI and designed a new window layout based on that size. Then I set my PC back to 100% DPI and ran the code without changing it, and the layout was still correct. I must admit, I wasn't expecting that. Thanks srod, for the enlightenment!srod wrote:For anyone who is laying out a UI which will automatically rescale for use on other systems then they need to take into account the DPI in force at the time they designed the UI. So, if they laid out the UI under a 300 DPI setting then they need :There is then no problem running this program on other systems (in theory at least) without any changes providing the /300 stays.Code: Select all
Global dpi.d=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)/300
Code: Select all
Global dpi.d=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)/125
OpenWindow(0,200,200,210*dpi,105*dpi,"test",#PB_Window_SystemMenu)
x=10*dpi
w=190*dpi
h=25*dpi
TextGadget(1,x,10*dpi,w,h,"This is text that fills the gadget",#PB_Text_Border)
StringGadget(2,x,40*dpi,w,h,"Another small test of fitted text")
ButtonGadget(3,x,70*dpi,w,h,"And last example of exact text")
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow