Tiffany
Tiffany

Reputation: 13

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%?

Upvotes: 0

Views: 1344

Answers (1)

ashleedawg
ashleedawg

Reputation: 21619

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 — XLarge 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

Upvotes: 3

Related Questions