Results 1 to 13 of 13
  1. #1
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    668
    Thanks
    3
    Thanked 21 Times in 19 Posts

    VBA userforms and Windows 7's custom dpi

    Does anyone have any wisdom on this?

    Windows 7 has a fairly cool feature that allows you to enlarge text and other items while retaining the native resolution of your display. I set mine to custom at 110%, but I have the following issue at any increased dpi.

    If I open a userform in Word, the text and sometimes the controls get too big for the userform, or display over each other. The background graphic I have on the form doesn't get bigger, so sometimes I see the edges of the graphic within the enlarged userform.

    Is there a way to increase dpi without affecting the userforms? On today's laptops, I can't imagine anyone not using the Set custom text size (DPI). Or, is there a way to have the userform and any graphics enlarge proportionally?

    Any advice on how to design userforms for Windows 7? Thanks!!
    Kim

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Kim,

    I've been trying to figure this same thing out for years. You're getting into the land of TWIPS! Did you know there are 1440 twips to the inch? I gave up long ago because it was just too much overhead to ask the paying customer to fund. You'd think Microsoft would have built the scaling into the OS or at least Office so that all the dialogs would autosize but not so. I guess there just hasn't been enough outcry from the VB & VBA community for Microsoft to take note.

    I'm hoping someone out there will make a complete fool of me on this post and show us how to easily do it. I'll be more than glad to eat my words w/o salt!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. #3
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    668
    Thanks
    3
    Thanked 21 Times in 19 Posts
    Hey RetiredGeek (may I call you "Retired" or do you prefer "Mr. Geek"? )

    I posted after some very ineffective Googling. Since then I happened to fall upon the phrase "DPI Aware" and have now read several articles, blogs and forum postings that did absolutely nothing to enlighten me.

    <<Huge Sigh>> After living a sheltered life on XP, I'd just like to find a simple, logical approach to handling vba userforms in the land of TWIPS. I'd rather stop my forms from trying to auto-size. Better they appear small than goofy-looking.

    Quote Originally Posted by RetiredGeek View Post
    I'll be more than glad to eat my words w/o salt!
    Best to save that salt for the rim of the Margarita glass.

    Thanks! Kim

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Quote Originally Posted by kmurdock View Post
    Hey RetiredGeek (may I call you "Retired" or do you prefer "Mr. Geek"? )
    Kim, actually I prefer the title hung on me by Just Plain Fred in another post... "Your Geekness"
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  5. #5
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    668
    Thanks
    3
    Thanked 21 Times in 19 Posts
    As you wish, Your Geekness.


    (<-- They're not doing the wave... they're bowing in obeisance.)


    Kim

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    I think it might be necessary to add code to UserForms (e.g., Initialize event) that can resize them in the event that they are too small for their contents. For example, you might have a label that you know is a certain size in relation to the form. The problem of controls overlapping is harder to solve...

  7. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Kim,

    Here's a little code I use to make sure multiple forms don't overlap. The code is placed in the respective Form_Open event code.

    Form1:
    Code:
       DoCmd.MoveSize 0, 0
    Loads 1st form at top left corner of Access Screen.

    Form2:
    Code:
       With Forms!frmOwnerInput.Form
         DoCmd.MoveSize .WindowLeft, .WindowTop + .WindowHeight + 288, 13300
       End With
    Loads 2nd form a fixed number of Twips {288} below the 1st form {frmOwnerInput}.

    This seems to insure that no matter the size of the screen my multiple forms don't overlap. I hope this is of some usefulness to you.
    Last edited by RetiredGeek; 2011-01-30 at 20:34.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,939
    Thanks
    0
    Thanked 94 Times in 90 Posts
    Interesting question. I suspect you would need API (don't know which one(s) offhand) to get the adjustment scale and then adjust the form and each control's size as applicable.
    Regards,
    Rory
    Microsoft MVP - Excel.

  9. #9
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    668
    Thanks
    3
    Thanked 21 Times in 19 Posts
    Your Geekness,

    Thanks for the code; I'm sure I can transpose to Word vba. I rarely have more than one userform on the screen at once, but it does happen.

    Rory,

    Thank you for your comment. I did find reference to API calls while Googling, but was overwhelmed by the idea of adding code to every userform I've built. I know, once the code works it's just a matter of adding, but oh! oh! oh!

    However, here's what I've discovered in working with this fairly extensively over the last few days:

    First, I found that Windows 7 does an excellent job of scaling everything on a userform except the background graphic. I expanded the background, pinned it to the upper right corner and now it looks fine up to 125% Beyond that I'm not sure the userforms themselves would be completely visible on a laptop. If I find there is a pressing need to go up to, say, 150%, then I can adjust.

    Regarding the control that caused my greatest concern, it was the calendar control that is no longer being distributed with Office 2010. Microsoft has assumed that everyone will be able to use the Date Picker instead. That's fine within a form document or in Access, but I want people to be able to look at a tiny calendar, pick a date and insert date text into a document (without the funny frame that the Date Picker uses).

    So, when I opened the userform that had the calendar control on it, I was missing an object (note to programmers, this causes an error message something like "object is missing or unavailable on this computer").

    I installed the calendar .ocx from 2007, registered it on the computer and ran the form. The calendar control appeared oversized. This is what I was worried about. However, I resized it in 100% mode and it has retained its relative size, despite changing the dpi.

    So that's where I am and I thank you both for you input.

    Kim

  10. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Quote Originally Posted by kmurdock View Post
    Your Geekness,
    I did find reference to API calls while Googling, but was overwhelmed by the idea of adding code to every userform I've built.
    Kim,

    If you could make sense of this you could write the code into Public Procedures that could be called from any userform then just make the appropriate calls with parameters. Thus, avoiding copying it into all userforms.

    Can't wait to see the code!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  11. #11
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    668
    Thanks
    3
    Thanked 21 Times in 19 Posts
    Your Geekness,

    Well of course, you're right.

    But you might be waiting a while for that code... I will surely try it when I have the time, but wasn't it you who said "I gave up long ago because it was just too much overhead to ask the paying customer to fund"??

    On the other hand, if it turns out to be easy (and by golly, it may!), I will post the code and even supply the salt. In the meantime, I will size my background graphics appropriately.

    Thanks again,
    Best, Kim

  12. #12
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Kim,

    OK! Since I'm currently in Southern Texas I'll hop across the border for the Tequila...
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  13. #13
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    For your interest - other languages

    As a programmer on other systems, you may find it interesting to note that most other languages' dialog-box layout sytems automatically cater for widegets changing size. This can be when you translate the labels into another (more wordy) language, or change font sizes as you mention.
    All the widgets 'jiggle' themselves under the direction of a 'layout manager' to stop them overlapping. It can be like a Word table resizing the columns.
    It works this way in Java, Perl/Tk, Python Tkinter and others.
    It's more work to set up to start with,though.
    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •