Windows 7 sizing
Windows 7 sizing
When switching Windows 7 to large fonts, it seems to fully upscale the whole window, all gadgets etc. In other words: under Windows XP I open a window at 10,10 with a size of 100,100. When opening the same window under Windows 7, with fonts set to large, it appears that Windows 7 (Aero?) upscales everything, except the screen coordinates, ie. it opens at 10,10, but the window is way larger, and so are the fonts being used...
Is it possible to *disable* the upscaling mechanism (for my specific applciation) or is there a way for me to see how much it is going to be upscaled by Windows 7?
Is it possible to *disable* the upscaling mechanism (for my specific applciation) or is there a way for me to see how much it is going to be upscaled by Windows 7?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- User
- Posts: 16
- Joined: Fri Jul 16, 2010 3:54 pm
Re: Windows 7 sizing
Do a search on scaling and Vista: you'll get plenty of answers.blueznl wrote:When switching Windows 7 to large fonts, it seems to fully upscale the whole window, all gadgets etc. In other words: under Windows XP I open a window at 10,10 with a size of 100,100. When opening the same window under Windows 7, with fonts set to large, it appears that Windows 7 (Aero?) upscales everything, except the screen coordinates, ie. it opens at 10,10, but the window is way larger, and so are the fonts being used...
Is it possible to *disable* the upscaling mechanism (for my specific applciation) or is there a way for me to see how much it is going to be upscaled by Windows 7?
Re: Windows 7 sizing
Yeah, found many, but haven't found anything that I could turn into code yet. Otherwise I wouldn't try my luck here 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- User
- Posts: 16
- Joined: Fri Jul 16, 2010 3:54 pm
Re: Windows 7 sizing
From what you describe I assume you do not mean large fonts in the UI but the DPI-scaling.blueznl wrote:Yeah, found many, but haven't found anything that I could turn into code yet. Otherwise I wouldn't try my luck here
Instead of disabling it ( overriding the user settings .. ) I simply adapt like this:
Code: Select all
Global scale.d = 96 / GetDeviceCaps_(GetDC_(0), #LOGPIXELSX) ; scale as compared to default 96 dpi
F_normal = Int(scale*10); 10 point font on XP
Global FontID1
FontID1 = LoadFont(1, "Arial", F_normal, #PB_Font_Bold)
Compile with XP skin support on. Does it for me on Vista and W7.
Re: Windows 7 sizing
Hmpf. I think I'll have to add some pictures, as it appears I'm not expressing myself clear enough. Don't worry, that happens a lot to me 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Windows 7 sizing
Ah! Found it! Or this is what I could figure out thus far... If I made a mistake, or someone has additional info, please reply as I think about turning this into a Survival Guide page.
Here's what happens (I think):
Windows 7 and Vista have an 'XP-style DPI / XP compatible DPI scaling mode' (or whatever you want to call it). By default, XP, Vista ad Win7 are set to 96 DPI.
On XP, changing the DPI does change the elements of the Windows GUI, as well as the size of fonts being drawn even those inside a PureBasic program. On Vista and Win7 you can disable 'XP style DPI' and then suddenly everything changes...
In addition, on XP you can als set the font to 'large' but this does not affect the DPI, it only affects Windows GUI elements.
In XP-style DPI.
In 'XP-style DPI' everything works like Windows XP (little surprise there):
It seems anything above 120 DPI (144 DPI?) is considered 'high DPI' and might yield different results but I'm not totally sure yet. Still looking into it
Non XP-style DPI.
With XP style DPI disabled things work differently: now everything which is not 'high DPI aware' is going to be resized / scaled automatically, or at least that's the concept
Some values will be adjusted accordingly, so if DPI is set to 150 in non-XP mode, your application on a 1680x1050 screen will be 'enlarged' as if the screen was only 1075x672 pixels.
High DPI aware code.
Still working on this one, but to use high DPI values you seem to have to do a bit of additional work outside of your code.
Here's what happens (I think):
Windows 7 and Vista have an 'XP-style DPI / XP compatible DPI scaling mode' (or whatever you want to call it). By default, XP, Vista ad Win7 are set to 96 DPI.
On XP, changing the DPI does change the elements of the Windows GUI, as well as the size of fonts being drawn even those inside a PureBasic program. On Vista and Win7 you can disable 'XP style DPI' and then suddenly everything changes...
In addition, on XP you can als set the font to 'large' but this does not affect the DPI, it only affects Windows GUI elements.
In XP-style DPI.
In 'XP-style DPI' everything works like Windows XP (little surprise there):
The above can lead to a surprise when you change the DPI settings and draw a font, so you have to adjust the font size using GetDeviceCaps_(), but that's it. Frankly, I think font size shouldn't change with a different DPI setting, as no gadgets are resized in XP-style DPI mode.- DesktopWidth() reports actual screen width
- GetSystemMetrics_() reports actual screen width
- GetDeviceCaps_() reports actual screen width and actual DPI
- GUI elements are drawn using the actual DPI setting
- Windows positions are drawn on given screen coordinates
- Fonts are drawn using a font based on DPI setting
It seems anything above 120 DPI (144 DPI?) is considered 'high DPI' and might yield different results but I'm not totally sure yet. Still looking into it

Non XP-style DPI.
With XP style DPI disabled things work differently: now everything which is not 'high DPI aware' is going to be resized / scaled automatically, or at least that's the concept

For all practial purposes, your application runs as if it was running on a Windows XP box with a different screen size and a DPI of 96. Unfortunately, except for WinApi, there's no way to find out the 'adjusted' screen size, as DesktopWidth() reports the physical screen size regardless of DPI settings so if you're using DesktopWidth() and its brethern be aware...- DesktopWidth() keeps reporting actual screen width
- GetSystemMetrics_() reports the adjusted screen width
- GetDeviceCaps_() reports the adjusted screen width and always 98 DPI
- GUI elements are drawn using the real DPI setting (pro rato upscaled)
- Windows positions are drawn on adjusted screen coordinates
- Fonts are pro rato upscaled
High DPI aware code.
Still working on this one, but to use high DPI values you seem to have to do a bit of additional work outside of your code.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- User
- Posts: 16
- Joined: Fri Jul 16, 2010 3:54 pm
Re: Windows 7 sizing
What is wrong with using WinApi?blueznl wrote: For all practial purposes, your application runs as if it was running on a Windows XP box with a different screen size and a DPI of 96. Unfortunately, except for WinApi, there's no way to find out the 'adjusted' screen size, as DesktopWidth() reports the physical screen size regardless of DPI settings so if you're using DesktopWidth() and its brethern be aware...
Perhaps you should attach a picture to clarify the problem. Keep in mind that dpi-aware programming is what MS expects from us ....
Re: Windows 7 sizing
Well, IMHO PureBasic should be reasonably self contained, leaving the WinApi stuff for experienced coders and special purposes.
I'm working on a Survival Guide page with some images. Have you ever tried setting DPI to 200 and run some code on it? (Turn XP-style DPI off.) Interesting results
I'm working on a Survival Guide page with some images. Have you ever tried setting DPI to 200 and run some code on it? (Turn XP-style DPI off.) Interesting results

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Windows 7 sizing
And here are some examples for the non-believers (scroll down and look at the last two images)...
http://www.xs4all.nl/~bluez/purebasic/p ... 17.htm#top
Which is what prompted me to add a feature request here...
http://www.purebasic.fr/english/viewtop ... 21&start=0
http://www.xs4all.nl/~bluez/purebasic/p ... 17.htm#top
Which is what prompted me to add a feature request here...
http://www.purebasic.fr/english/viewtop ... 21&start=0
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Windows 7 sizing
@bluezl
This is probably the best thread on the forum about this (not just because it's my thread), reading the conversation in the thread should give more understanding on how this work.
Or if your just lazy, try out the example source in the first post.
http://www.purebasic.fr/english/viewtop ... 7&p=310974
This is probably the best thread on the forum about this (not just because it's my thread), reading the conversation in the thread should give more understanding on how this work.
Or if your just lazy, try out the example source in the first post.
http://www.purebasic.fr/english/viewtop ... 7&p=310974
Re: Windows 7 sizing
Thanks for the link, Rescator, I must have missed it at the time. I'm going to study it and see where I got things right and where I have them wrong 
The Survival Guide typically grows whenever I run into an issue myself, and DPI / font-sizing was one of them. Perhaps this time I'll simply borrow some of your stuff to save me time

The Survival Guide typically grows whenever I run into an issue myself, and DPI / font-sizing was one of them. Perhaps this time I'll simply borrow some of your stuff to save me time

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Windows 7 sizing
By all means do so. the license in this case is Public Domain, other times it's a very friendly zlib/MIT license,
and if no license is stated at all then consider it Public Domain really, the forum is publicly readable after all
I added that thread to the Windows Forum FAQ to hopefully make it easier to find for others in the future: http://www.purebasic.fr/english/viewtop ... =5&t=34334
and if no license is stated at all then consider it Public Domain really, the forum is publicly readable after all

I added that thread to the Windows Forum FAQ to hopefully make it easier to find for others in the future: http://www.purebasic.fr/english/viewtop ... =5&t=34334
Re: Windows 7 sizing
Yeah, the devs might consider making that thread sticky, I guess it would help some people.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Windows 7 sizing
I still think scaling the fonts down again is just horribly wrong. When users increase the dpi it is because they need larger fonts. If you position your text with the knowledge of TextHeight() and TextWidth() then it shouldn't be a big problem. Yes it looks ugly, but so what if the alternative is that the user simply cannot read it?
Re: Windows 7 sizing
Dunno, Trond. I think it's the application that should decide what to do if a user changes the DPI settings. It shouldn't be PureBasic that decides.
Indeed, people increasing the DPI do so with a reason: they want a larger GUI and font, but if the application does not modify its gadget sizes, the result will be horrid.
Assume an application draws a line on the screen, that line would still be the width orginally set by the programmer. According to your logic, on systems setting a higher DPI lines would get thicker as well. That doesn't make sense either.
So, when I build an object of 20 pixels high, and put a text with specified font on it, it's up to me to decide if I want to support a higher DPI setting. If I want to, then I will enlarge my gadgets, as well as increase the font.
Indeed, people increasing the DPI do so with a reason: they want a larger GUI and font, but if the application does not modify its gadget sizes, the result will be horrid.
Assume an application draws a line on the screen, that line would still be the width orginally set by the programmer. According to your logic, on systems setting a higher DPI lines would get thicker as well. That doesn't make sense either.
So, when I build an object of 20 pixels high, and put a text with specified font on it, it's up to me to decide if I want to support a higher DPI setting. If I want to, then I will enlarge my gadgets, as well as increase the font.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )