-
Oct 13th, 2015, 12:17 PM
#1
Thread Starter
Member
Adjust form for 125% font sizes on Windows Vista or higher?
Hey all,
I have a project that runs fine at 1366x768 using normal font sizes and a main MDI form with child forms loaded into it.
If a user sets their system to 125% font size however, the display messes up and is too large for the fonts in it, and everything is out of whack. With my setup described above, how do I adjust the form display for 125% font sizes on Windows Vista all the way through Windows 10, with a MDI form setup?
Thanks!
-
Oct 13th, 2015, 01:03 PM
#2
Re: Adjust form for 125% font sizes on Windows Vista or higher?
Not sure what this statement means exactly, cannot visualize it: "... the display messes up and is too large for the fonts in it". One thing you should be doing is using TrueType or OpenType fonts.
-
Oct 13th, 2015, 01:20 PM
#3
Thread Starter
Member
Re: Adjust form for 125% font sizes on Windows Vista or higher?
I always use TT fonts only for my apps. I use an external image and load it into the form's Picture property, for reference as well.
Here's an example of a screen. Below is how it normally should look:
http://corrupted-streets.com/goodscreen.jpg
Now with 125% font size on Windows 7, for example:
http://corrupted-streets.com/badscreen.jpg
What the easiest and simplest way to deal with this? I use all TT fonts, 1366x768 window sizes and just the default text labels with images loaded onto the Picture property of a MDI child form.
-
Oct 13th, 2015, 01:39 PM
#4
Thread Starter
Member
Re: Adjust form for 125% font sizes on Windows Vista or higher?
It seems Windows 7 is the worst with this. Windows 10 seems to scale the form up automatically.
-
Oct 13th, 2015, 01:40 PM
#5
Re: Adjust form for 125% font sizes on Windows Vista or higher?
I think you have 3 basic options:
1) Allow your form to scale with the user's DPI settings (125%)
- If using a picture box with AutoSize=True, you will not want to do that. It prevents VB from scaling it to system DPI because VB does not scale images; picbox is tied to image size. If this is the case, you'll want to resize your picbox image to the picbox size (Resize event)
- If using Image controls, set the image control .Stretch property to True
- Re-work how you are spacing things. Looks like you may be hardcoding some offsets, X,Y coordinates?
2) Resize your form, along with all the fonts, and controls to an equivalent of 96 DPI (100%)
- This can be more difficult than #1 above
- Basically, you query the system DPI and if not 96 DPI (100%), you would down-scale the control sizes, positions, font sizes and of course, the form dimensions itself. Resizing the form can have unwanted results regarding menus & captions
- Form will appear smaller than the user expects
3) Prevent DPI scaling. The user can attempt this via the property page from right clicking on the exe. Your app may look pretty ugly
-
Oct 13th, 2015, 01:48 PM
#6
Thread Starter
Member
Re: Adjust form for 125% font sizes on Windows Vista or higher?
#3 doesn't work...just tried it.
#1: I load an external picture into the Picture property of the form itself, I don't use a Image or Picturebox control. How would I do this for proper form scaling?
#2: What would be the code for #2, if I wanted to try it?
Last edited by derek412; Oct 13th, 2015 at 01:54 PM.
-
Oct 13th, 2015, 01:58 PM
#7
Re: Adjust form for 125% font sizes on Windows Vista or higher?
1. A quick test to determine what DPI scale that VB believes it is running in:
DPI = 1440 / Screen.TwipsPerPixelX
2. For a picturebox, you can use VB's PaintPicture. Ensure AutoSize = False and then during Picbox Resize event and using an external image:
Code:
Dim tPic As StdPicture
Set tPic = LoadPicture(path/filename of external image)
picCanvas.AutoRedraw = True
picCanvas.PaintPicture tPic, 0, 0, picCanvas.ScaleWidth, picCanvas.ScaleHeight
The above code assumes that the picturebox is already properly scaled to whatever image will be displayed in it. When run in a different DPI, VB will scale the picturebox to the new DPI and that scale will be proportional to what it was before it was scaled; therefore, drawing the image to the picbox new size should produce a proportionally scaled image
For a more professional result, your images would likely contain multiple sizes for various DPI scales. Or possibly one larger size that would scale down very well and not look to bad if scaled up slightly. Images scale far better down than up, generally speaking
-
Oct 13th, 2015, 02:06 PM
#8
Thread Starter
Member
Re: Adjust form for 125% font sizes on Windows Vista or higher?
I'm not currently using a Picturebox, as I stated. Is there a fairly simple way to scale the form itself in Windows 7 if the user's DPI is set to 125%, if the image is being loaded directly into the Picture property of a form?
-
Oct 13th, 2015, 02:13 PM
#9
Re: Adjust form for 125% font sizes on Windows Vista or higher?
You mean to scale the form back to what it would be if it were in 96 DPI? Not sure you want to do that because all of your controls are scaled larger under a higher DPI (125% larger in this case).
If you are asking how to scale everything to 125% then VB does that for most of VB stuff (graphics and anything without a Top, Left, Width or Height property being notable exceptions). If your app is running in virtualized DPI, then it thinks it is running at 96 DPI when the system is something other: 125, 150, 200 DPI, etc. Is this what you are asking? How to scale everything up? From your screen shots, appears VB is already scaling the form & controls, but not the graphics (which it won't do).
P.S. sorry about the picturebox solution. It still works with the form, just change picCanvas to Me.
If that won't work, I can show you how to scale a picture property
-
Oct 13th, 2015, 02:30 PM
#10
Re: Adjust form for 125% font sizes on Windows Vista or higher?
Also keep in mind that some types of images will auto scale with the form. I use WMF files for example and they auto strech/shrink as needed when the form is resized no code required.
-
Oct 13th, 2015, 02:36 PM
#11
Re: Adjust form for 125% font sizes on Windows Vista or higher?
As DM said, metafiles do scale (vector vs raster graphics), which is why TrueType fonts scale well also.
To scale your form's picture (picture property), two methods: API or VB. Here's the VB version:
1) Add a picturebox to your form, set its Visible property to False and BorderStyle to zero
2) In the form's Resize event, you can add this:
Code:
Private Form_Resize()
On Error GoTo ExitRoutine ' or check for minimize
With picImgResizer
.ScaleMode = Me.ScaleMode
.Move .Left, .Top, Me.ScaleWidth, Me.ScaleHeight
.AutoRedraw = True
.PaintPicture Me.Picture, 0, 0, .ScaleWidth, .ScaleHeight
Set .Picture = .Image
Set Me.Picture = .Picture
.AutoRedraw = False
Set .Picture = Nothing
End With
ExitRoutine:
Exit Sub
Edited: The above solution should only be used one time. If it is possible the form can be resized multiple times, then you will seriously lose image quality. In that case, the picture to be scaled should be cached and used each time rescaling is needed. The above routine will rescale the original image and replace it.
Last edited by LaVolpe; Oct 13th, 2015 at 02:40 PM.
-
Oct 13th, 2015, 09:11 PM
#12
Re: Adjust form for 125% font sizes on Windows Vista or higher?
I personally believe that MS should have it's head examined for ever offering that option in Windows.
No doubt it is possible to code for users changing text size, but I have even seen MS applications that cannot handle that.
I just advise my users to put it back to 100% the way God intended.
And tell them if they are old and feeble sighted (like me), to come up with a 'cleaner' solution such as -
- Use a larger LCD TV as a monitor (I am at 40" these days),
OR
- Get some screen magnification program, that can with a single key stroke, double the magnification of the full screen.
(I have one of those as well.)
(The inbuilt one in W10 is nearly as good as mine)
-
Oct 13th, 2015, 10:00 PM
#13
Re: Adjust form for 125% font sizes on Windows Vista or higher?
I use a 37 @1920x1024 and use 125% as the text is just to small at the default size.
The options for increased font sizes are very good to have in there. It is out job as programmers to make sure our programs work for our intended users and not force them to use a magnifing glass to read the text on the screen. A lot of people use laptops with high res but small screens the increased fonts sizes are very important to have there and really should not cause any issues if the program is designed well.
I think the last time I saw an issue related to increased font sizes was back in Windows NT when someone was using large fonts at 800x600 res caused some stuff to be pushed off the screen
-
Oct 13th, 2015, 10:43 PM
#14
Re: Adjust form for 125% font sizes on Windows Vista or higher?
If I can illustrate the lack of logic in MS's 'unclean' option, and your support of it.
Let me know when your eyesight gets a lot worse.
I will ask MS to allow a change of the TEXT DPI setting to 500%
-
Oct 14th, 2015, 12:42 AM
#15
Re: Adjust form for 125% font sizes on Windows Vista or higher?
Originally Posted by Bobbles
If I can illustrate the lack of logic in MS's 'unclean' option, and your support of it.
Let me know when your eyesight gets a lot worse.
I will ask MS to allow a change of the TEXT DPI setting to 500%
The option to increase text size is nothing new, It has been a part of Windows for at least 20 years now and it does make computers easier to use in many cases for many people.
There is nothing wrong with it and honestly I have yet to install or create a single program that had any issues with it.
Actually I said I use 125% but re-reading the thread I think i am talking about something else. Windows has options for setting the text size in windows and I run them at medium which is one step up from the default. I would guess that is about 125% that has been around for at least 20 years now, can't remember if it was in Windows 3.1 or not but has been in all the 32 and 64 bit versions.
I would guess that the DPI scaling is due to some of the very high res setting on some of the newer and small monitors. With the default DPI and text size any text would be very hard to read even with 20/20 vision and impossible for those of us without.
Last edited by DataMiser; Oct 14th, 2015 at 12:49 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|