none
Coping with User Text-Size Changes - Desktop - VB.Net RRS feed

  • Question

  • I have a Windows Forms application for a Desktop Computer. One of the forms has its 'FormBorderStyle' set to 'FixedToolWindow'. The form contains a number of labels, textboxes, and at the bottom of the form, two buttons.

    One of my users reported that he could not see the two buttons: I eventually discovered that he changed the system text-size using 'Control Panel > Display > 125%'. The result was to make the label-text larger, and because the form was a fixed size, there was no room for the buttons any more.

    What is the best way to deal with this, in general? In this case the buttons disappeared, so I could of course reposition the buttons, but then something else would disappear and the user might not be aware that something was not there that should be!

    Monday, July 16, 2018 11:46 AM

Answers

  • Hi Les - thanks for helping, but I am not sure if this is quite the same issue. That code seems to react to someone who resizes the page. My problem is that it has been resized before the program starts, and the code is not aware that some of the controls are not visible.

    Hi

    OK, another left field idea to try - won't harm anything and *may* work.

    In the designer, assuming you have all the controls set appropriately and arranged as you need, drag/resize the form to something much smaller than you want - say 200x200 - and then resize to required size in the Form load event.

    A strange thing, but, as I also use Windows 10 with a high res screen and had to adjust font size the make text readable, the above is always needed in my apps. (as well as the IrtonRazerz code I mentioned where appropriate)


    Regards Les, Livingston, Scotland

    • Marked as answer by Tim_Makins Tuesday, July 17, 2018 2:31 PM
    Tuesday, July 17, 2018 1:42 PM
  • Thanks Reed - I did see the 'https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms' page, but it only has code for C#, not VB.Net. My VB.Net Windows Forms application doesn't seem to have an XML manifest file (that I could locate!). Also, I need my applications to work with Windows 7, not just the latest versions of Windows 10, as many people still use 7.

    It is for VB also.

    You add a manifest file by right clicking on the solution, going to Add -> New Item and selecting Application Manifest File from the General category.

    For previous versions of Windows you can set the DpiAware element instead of, or in addition to, the DpiAwareness element.  See DpiAware in the documentation for application manifest for more information.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Tim_Makins Wednesday, July 18, 2018 12:53 PM
    Tuesday, July 17, 2018 5:02 PM
    Moderator
  • It still might be handy to know if there is any way of the program knowing that some of its controls are not currently on view. Does anyone know of a way to identify this condition?

    If you make the application DPI aware, it should resolve the issue on its own for that simple form.  However, for the best results, I would still suggest putting all of the controls in a TableLayoutPanel and using anchoring and docking along with autosized labels.

    To get the functionality you are requesting, you'd have to write a little recursive routine to loop through all of the controls on the form (including controls within controls) and test to see if the bounds of each control are wholly contained within the client bounds of the form they are on.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Tim_Makins Wednesday, July 18, 2018 12:53 PM
    Tuesday, July 17, 2018 5:06 PM
    Moderator

All replies

  • Hi

    I use the code from IronRazerz in THIS thread, to deal with the exact same issue you mention.

    You would need to read the whole thread to pick up hints and modification discussions.


    Regards Les, Livingston, Scotland

    Monday, July 16, 2018 12:08 PM
  • Monday, July 16, 2018 12:13 PM
  • Note that in addition to the advice in the linked articles, it is best to layout all controls using TableLayoutPanel and/or FlowLayoutPanel as appropriate and then using docking or anchoring of controls in the panel along with autosize on labels.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, July 16, 2018 5:09 PM
    Moderator
  • Hi Les - thanks for helping, but I am not sure if this is quite the same issue. That code seems to react to someone who resizes the page. My problem is that it has been resized before the program starts, and the code is not aware that some of the controls are not visible.
    Tuesday, July 17, 2018 10:14 AM
  • You need to enable the high DPI support that Castorix31 linked, or at a minimum, set the application to be DPI aware in an app.manifest file.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, July 17, 2018 11:31 AM
    Moderator
  • Hi Les - thanks for helping, but I am not sure if this is quite the same issue. That code seems to react to someone who resizes the page. My problem is that it has been resized before the program starts, and the code is not aware that some of the controls are not visible.

    Hi

    OK, another left field idea to try - won't harm anything and *may* work.

    In the designer, assuming you have all the controls set appropriately and arranged as you need, drag/resize the form to something much smaller than you want - say 200x200 - and then resize to required size in the Form load event.

    A strange thing, but, as I also use Windows 10 with a high res screen and had to adjust font size the make text readable, the above is always needed in my apps. (as well as the IrtonRazerz code I mentioned where appropriate)


    Regards Les, Livingston, Scotland

    • Marked as answer by Tim_Makins Tuesday, July 17, 2018 2:31 PM
    Tuesday, July 17, 2018 1:42 PM
  • Thanks Reed - I did see the 'https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms' page, but it only has code for C#, not VB.Net. My VB.Net Windows Forms application doesn't seem to have an XML manifest file (that I could locate!). Also, I need my applications to work with Windows 7, not just the latest versions of Windows 10, as many people still use 7.
    Tuesday, July 17, 2018 2:30 PM
  • It still might be handy to know if there is any way of the program knowing that some of its controls are not currently on view. Does anyone know of a way to identify this condition?
    Tuesday, July 17, 2018 2:34 PM
  • Thanks Reed - I did see the 'https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms' page, but it only has code for C#, not VB.Net. My VB.Net Windows Forms application doesn't seem to have an XML manifest file (that I could locate!). Also, I need my applications to work with Windows 7, not just the latest versions of Windows 10, as many people still use 7.

    It is for VB also.

    You add a manifest file by right clicking on the solution, going to Add -> New Item and selecting Application Manifest File from the General category.

    For previous versions of Windows you can set the DpiAware element instead of, or in addition to, the DpiAwareness element.  See DpiAware in the documentation for application manifest for more information.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Tim_Makins Wednesday, July 18, 2018 12:53 PM
    Tuesday, July 17, 2018 5:02 PM
    Moderator
  • It still might be handy to know if there is any way of the program knowing that some of its controls are not currently on view. Does anyone know of a way to identify this condition?

    If you make the application DPI aware, it should resolve the issue on its own for that simple form.  However, for the best results, I would still suggest putting all of the controls in a TableLayoutPanel and using anchoring and docking along with autosized labels.

    To get the functionality you are requesting, you'd have to write a little recursive routine to loop through all of the controls on the form (including controls within controls) and test to see if the bounds of each control are wholly contained within the client bounds of the form they are on.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Tim_Makins Wednesday, July 18, 2018 12:53 PM
    Tuesday, July 17, 2018 5:06 PM
    Moderator