简体   繁体   中英

VBA detect window font size

I have a data load program which helps users to upload huge amount of data data to Oracle. But each user may have their own window resolution setting and the display font size.

Is there any code that can retrieve user's window font size? Either smaller 100%, or medium 125%?

You can get [or set] the Windows Desktop "zoom level" with the associated registry key:

HKEY_CURRENT_USER\\Control Panel\\Desktop\\LogPixels


Values:

96 – Smaller 100%
120 – Medium 125%
144 – Larger 150%
192 – Extra Large 200%
240 – Custom 250%
288 – Custom 300%
384 – Custom 400%
480 – Custom 500%


If your goal is to determine where to place something relative to the screen width & height, you might be better to just check actual screen resolution with something like:

Declare Function GetSystemMetrics32 Lib "User32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Sub ScreenRes()
Dim w As Long, h As Long
    w = GetSystemMetrics32(0) ' width in points
    h = GetSystemMetrics32(1) ' height in points
MsgBox "X=" & w & ", Y=" & h
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM