Results 1 to 15 of 15

Thread: Adjust form for 125% font sizes on Windows Vista or higher?

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    53

    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!

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    53

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    53

    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.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    53

    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.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    53

    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?

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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.

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    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)

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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

  14. #14
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    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%

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Adjust form for 125% font sizes on Windows Vista or higher?

    Quote Originally Posted by Bobbles View Post
    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
  •  



Click Here to Expand Forum to Full Width