What to do when GetDeviceCaps doesn't?

P

Phill W.

From what I've been reading, the code below /should/ pop up the Users
chosen Font Size (yes; I'm having to cross sword with "Large Fonts" some
... person .. decided to recommend it to our users).

Private Declare Function apiGetDeviceCaps Lib "gdi32.dll" _
Alias "GetDeviceCaps" ( _
ByVal hdc As IntPtr _
, ByVal iIndex As Integer _
) As Integer
Private Const LOGPIXELSX As Integer = 88

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)

Dim g As Graphics = Me.CreateGraphics()
Dim ip As IntPtr = g.GetHdc()
Dim i As Integer = apiGetDeviceCaps(ip, LOGPIXELSX)
g.ReleaseHdc(ip)
g.Dispose()

MsgBox(i)

End Sub

Lovely - except that it always seems to return 96, no matter what Font
Size I've selected in Control Panel.

Any suggestions?

TIA,
Phill W.
 
T

Tom Shelton

Phill said:
From what I've been reading, the code below /should/ pop up the Users
chosen Font Size (yes; I'm having to cross sword with "Large Fonts" some
.. person .. decided to recommend it to our users).

Private Declare Function apiGetDeviceCaps Lib "gdi32.dll" _
Alias "GetDeviceCaps" ( _
ByVal hdc As IntPtr _
, ByVal iIndex As Integer _
) As Integer
Private Const LOGPIXELSX As Integer = 88

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)

Dim g As Graphics = Me.CreateGraphics()
Dim ip As IntPtr = g.GetHdc()
Dim i As Integer = apiGetDeviceCaps(ip, LOGPIXELSX)
g.ReleaseHdc(ip)
g.Dispose()

MsgBox(i)

End Sub

Lovely - except that it always seems to return 96, no matter what Font
Size I've selected in Control Panel.

Any suggestions?

TIA,
Phill W.

Phill, this isn't returning the font size from the control panel.
Returns the logical pixels per inch of the screen width. This is
changed by hitting the advanced button on your display settings tab,
it's the DPI. By default this is 96. The font size is on the
appearences tab.

I think you might be looking for System.Drawing.SystemFonts.
 
P

Phill W.

Tom said:
this isn't returning the font size from the control panel.
Returns the logical pixels per inch of the screen width.

Oops. My mistake.
This is changed by hitting the advanced button on your display
settings tab, it's the DPI. By default this is 96. The font size
is on the appearences tab.

And it's the Font Size that my users have been "recommended" to change
and that I now need to work with.

I /think/ I saw that value being changed (in RegMon) but it's only
stored as the "listindex" of the list used to /select/ each size. Do
you know of any reference that defines how this setting affects the font
size used? I /assume/ that each one applies a "scaling" of some measure
to the default font size; if I knew what each scaling value was, I could
probably do what I need with that.
I think you might be looking for System.Drawing.SystemFonts.

I'm still using VS'2003 - I don't have a SystemFonts class (yet).

Regards,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top