Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Display Font small or large

Status
Not open for further replies.

Youngguy

Programmer
Aug 1, 2001
8
0
0
US
How can I determine if the Display Font is set to Small Font or Large Font?
 
Hi Young,

Here is some sample code I used which should help you...

Option Explicit
Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long

Private Sub Command1_Click()
'call the wrapper function
If IsScreenFontSmall() Then
Label1.Caption = "The system is using Small fonts"
Else
Label1.Caption = "The system is using Large fonts"
End If
End Sub


Private Function IsScreenFontSmall() As Boolean

Dim hWndDesk As Long
Dim hDCDesk As Long
Dim logPix As Long

'get the handle to the desktop window
hWndDesk = GetDesktopWindow()

'get the handle desktop display context (hDC)
hDCDesk = GetDC(hWndDesk)

'get the horizontal logical pixels
logPix = GetDeviceCaps(hDCDesk, LOGPIXELSX)

'release the hDC
Call ReleaseDC(hWndDesk, hDCDesk)

'if the return from GetDeviceCaps is 96, then
'the system is using small fonts.
IsScreenFontSmall = logPix = 96

End Function

============================

That Should Solve Your Problem

Ciao
Phathi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top