Userform controls and Windows display text size setting

GJL

New Member
Joined
Mar 26, 2011
Messages
17
Normally I keep my Windows display text size setting at 125% (in Windows 7, Personalize | Display).

But if I lay out a userform with controls while on that computer, then run it on another computer with the default setting (100%), text seems to become bigger, or maybe the controls holding them become smaller. Anyway, text is cropped in labels, listboxes get vertical scrollbars they don't have on my computer, etc. Controls carefully laid out to work together, such as an edit box right next to a listbox item named "Other:", are positioned all wrong relative to each other.

Why would the text seem to get bigger when going to a smaller text size setting?

And, what's the best practice when developing for use by others on other computers? Default 100%? Smaller than 100% to cover users who may have their Windows text size set smaller?

Aside from leaving gobs of white space, is it possible to make text in dialog controls look the same size regardless of the Windows text size setting?


Thanks,

Greg
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You need to resize the userform, controls and font size based on a scale measure of the system metric change. Program in 100% as your normal then scale everything based on the amount of change from the normal. Google GetSystemMetrics to start. HTH. Dave
 
Upvote 0
For cross platform sizing, you can use a control that supports .AutoSize to adjust the size of other controls in the Intialize event.
Something like

Code:
Private Sub UserForm_Initialize()
    Dim vSizeFactor As Double, hSizeFactor As Double
    Dim oneControl As Variant
    
    With Label1
        .Caption = "X"
        .AutoSize = True
        vSizeFactor = .Height / 18
        hSizeFactor = .Width / 12
        .Visible = False
    End With
    
    For Each oneControl In Array(CommandButton1, CheckBox1, ListBox1)
        With oneControl
            .Height = .Height * vSizeFactor
            .Width = .Width * hSizeFactor
        End With
    Next oneControl
End Sub
 
Upvote 0
Code:
Private Sub UserForm_Initialize()
 
'==================================================
'Resizes the userform in case system settings skew original dimensions
 
'Variable       Purpose
 
'a1             Single, dynamic height of autosize-enabled control
'a2             Single, dynamic left of autosize-enabled control
'a3             Single, dynamic top of autosize-enabled control
'a4             Single, dynamic width of autosize-enabled control
'==================================================
 
Dim a1, _
    a2, _
    a3, _
    a4      As Single
 
With Me.HandwrittenOnly
 
    a1 = .Height / 30
    a2 = .Left / 6
    a3 = .Top / 9
    a4 = .Width / 77
 
End With
 
With Me
 
    .Height = a1 * 70
    .Width = a4 * 185
 
    With .BothSheets
 
        .Height = a1 * 30
        .Left = a2 * 96
        .Top = a3 * 9
        .Width = a4 * 77
 
    End With
 
End With
 
End Sub

Mike, .Autosize doesn't change the size of the key button when the "Font Size" option in "Control Panel-> Display-> Appearance" is set to "Extra Large". The buttons remain clipped by the userform because the scale remains set to "1". So that solution doesn't seem to work.
 
Upvote 0
Dave, this function returns "0", which MSDN indicates may constitute a system failure. I was thinking I could use the minimum button size in a title bar to check the hegiht of the title bar (eg, whether it has been stretched).

Am I on the right track with this? What parameter should I be using here?

Standard module:

Code:
Private c1 As Class1
Public Sub test()
Set c1 = New Class1
c1.test123
End Sub

Class module:

Code:
Private Declare Function GetSystemMetrics Lib "user32" (nIndex) As Integer
Public Sub test123()
Debug.Print GetSystemMetrics(31)
End Sub
 
Upvote 0
In fact, I don't see any parameter that refers either to "font size" or "title bar" in a way that would be useful with this problem.

Anyone have any ideas on this?

Edit: I'm thinking something like SM_CYSCREEN? The Int nIndex = 1.

Find it on your original system and then apply it? The display pixel dimensions don't haev to change for your userform to be skewed, but maybe it's one element that could cause problems...?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top