ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   monitor small/large font code (https://www.excelbanter.com/excel-programming/295805-monitor-small-large-font-code.html)

Tom Rudski[_2_]

monitor small/large font code
 
Need code to determine the monitor/screen setting 'small font' or 'large font'
I have code for screen resolution
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small font 96 dpi normal'

TIA

Vasant Nanavati

monitor small/large font code
 
Sub GetScreenFont()
MsgBox GetDeviceCaps(GetDC(0), 88), vbOKOnly _
+ vbInformation, "Screen Font Size"
End Sub

Assuming you have already declared the GetDC and GetDeviceCaps functions to
get the screen resolution.

--

Vasant

"Tom Rudski" wrote in message
...
Need code to determine the monitor/screen setting 'small font' or 'large

font'.
I have code for screen resolution.
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small font

96 dpi normal'.

TIA




Bob Phillips[_6_]

monitor small/large font code
 
Here's a slightly modified bit of code from Randy Birch

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Copyright ©1996-2004 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
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 Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90


Public Function ScreenFont() As String
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.
If logPix = 96 Then
ScreenFont = "Small"
Else
ScreenFont = "Large"
End If

End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Rudski" wrote in message
...
Need code to determine the monitor/screen setting 'small font' or 'large

font'.
I have code for screen resolution.
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small font

96 dpi normal'.

TIA




Vasant Nanavati

monitor small/large font code
 
88 represents a constant (named LOGPIXELX) used for convenience. It has no
inherent significance that I know of. It is one of the many parameters for
the function GetDeviceCaps which can give you all kinds of information about
an output device.

--

Vasant



"Tom Rudski" wrote in message
...
Thanks to both responses. Naturally both work.

question when you passed the '88' parameter to GETDC.
What other values can I pass. I look into MS reference and they do npt

provide other values.
Where can I find values other than '88' and see what they provide.

TIA




Bob Phillips[_6_]

monitor small/large font code
 
Make sure that you release the DC, see
http://msdn.microsoft.com/library/de...vcons_4esj.asp

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Sub GetScreenFont()
MsgBox GetDeviceCaps(GetDC(0), 88), vbOKOnly _
+ vbInformation, "Screen Font Size"
End Sub

Assuming you have already declared the GetDC and GetDeviceCaps functions

to
get the screen resolution.

--

Vasant

"Tom Rudski" wrote in message
...
Need code to determine the monitor/screen setting 'small font' or 'large

font'.
I have code for screen resolution.
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small

font
96 dpi normal'.

TIA






Bob Phillips[_6_]

monitor small/large font code
 
Take a look at
http://msdn.microsoft.com/library/de...vcons_88s3.asp
and http://www.mentalis.org/apilist/GetDeviceCaps.shtml

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Rudski" wrote in message
...
Thanks to both responses. Naturally both work.

question when you passed the '88' parameter to GETDC.
What other values can I pass. I look into MS reference and they do npt

provide other values.
Where can I find values other than '88' and see what they provide.

TIA




Vasant Nanavati

monitor small/large font code
 
Hi Bob:

I didn't realize the DC needed to be released if you weren't doing anything
with it (besides getting the handle), but my API knowledge would probably
fit on the head of a pin <g.

Regards,

Vasant.

"Bob Phillips" wrote in message
...
Make sure that you release the DC, see

http://msdn.microsoft.com/library/de...vcons_4esj.asp

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Sub GetScreenFont()
MsgBox GetDeviceCaps(GetDC(0), 88), vbOKOnly _
+ vbInformation, "Screen Font Size"
End Sub

Assuming you have already declared the GetDC and GetDeviceCaps functions

to
get the screen resolution.

--

Vasant

"Tom Rudski" wrote in message
...
Need code to determine the monitor/screen setting 'small font' or

'large
font'.
I have code for screen resolution.
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small

font
96 dpi normal'.

TIA








Bob Phillips[_6_]

monitor small/large font code
 
Hi Vasant,

you probably haven't run into the problems that can arise, so it didn't
seem like an issue. Defensive programming<vbg

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Hi Bob:

I didn't realize the DC needed to be released if you weren't doing

anything
with it (besides getting the handle), but my API knowledge would probably
fit on the head of a pin <g.

Regards,

Vasant.

"Bob Phillips" wrote in message
...
Make sure that you release the DC, see


http://msdn.microsoft.com/library/de...vcons_4esj.asp

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Sub GetScreenFont()
MsgBox GetDeviceCaps(GetDC(0), 88), vbOKOnly _
+ vbInformation, "Screen Font Size"
End Sub

Assuming you have already declared the GetDC and GetDeviceCaps

functions
to
get the screen resolution.

--

Vasant

"Tom Rudski" wrote in message
...
Need code to determine the monitor/screen setting 'small font' or

'large
font'.
I have code for screen resolution.
In Control Panel, 'Display', my 'Settings' advanced tab shows 'small

font
96 dpi normal'.

TIA










All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com