473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

What to do when GetDeviceCaps doesn't?

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.
Aug 18 '06 #1
2 2311

Phill W. wrote:
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.

--
Tom Shelton [MVP]

Aug 18 '06 #2
Tom Shelton wrote:
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.
Aug 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
2
by: Al Bahr | last post by:
H I am try to convert C# to vb.net I don’t know what would be an equivalent statements in VB.net any help will be appreciated. bmiColors ' RGBQUAD structs... Blue-Green-Red-Reserved, repeat.....
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
3
by: Nancy | last post by:
BlankFollowing is the code I'm using in an attempt to determine the hard margins of a printer and adjust the print margins accordingly. I'm only showing the retrieval of info (not the manipulating)...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.