Text/Font size in Windows?

This is a discussion on Text/Font size in Windows? within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, I need to find out what kind of text size a user uses in Windows. Like if the ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    158

    Text/Font size in Windows?

    Hi there, I need to find out what kind of text size a user uses in Windows. Like if the user has chosen "Default scale" or "Large Scale" (DPI scaling) in Windows Vista. It should work for Windows generally though, also in XP. Any idea?
    home = hat.position;

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    By this I mean the text that would be used in the caption of a window as an example. I need to know if the user uses a large text and if so make the window wider so that the text fits.

    I found this function but I'm not sure if it does what I want: GetSystemMetrics
    GetSystemMetrics Function (Windows)
    home = hat.position;

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I had the same issue about 7 years ago, can't remember what I did to fix it (not sure if it was before the move to the new board in Aug 2001 and so got lost).

    Have you looked at GetTextExtentPoint32() to check the size?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    GetSystemMetrics() should give you the default height values. I believe this comes from the settings you can alter in the display properties like colors, font sizes, etc.

    GetTextExtentPoint32() will give you the font size information for the font that is currently selected into the DC - which has nothing to do with the GetSystemMetrics() information.

    I would agree with novacain and use the latter of the two functions.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Thanks, it seems that what you get from GetTextExtentPoint32 is not affected by changing the size of the text that is used in window captions and menus though so it is not what I'm looking for. Similar info could also be got from GetSystemMetrics where you can get the average character width but again it is not what I need.
    home = hat.position;

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    GetSystemMetrics() should be able to tell you the font and the size of the font for window captions or title bars.

    http://msdn.microsoft.com/en-us/libr...95(VS.85).aspx
    http://msdn.microsoft.com/en-us/libr...21(VS.85).aspx

    There has to be a function in there that does what you want.
    Last edited by VirtualAce; 12-12-2009 at 12:56 PM.

  7. #7
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    612

  8. #8
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Quote Originally Posted by adeyblue View Post
    Thanks a lot, those works to get the size when the DPI has changed. There is another, perhaps more common way, to change the character size in the display properties though and that does not get reflected in the output of those functions. That setting can be found when you righ-click the desktop, choose properties, appearence tab, and then go to the bottom dropdown list (in XP). Any idea how to get the size based on that?
    Last edited by DrSnuggles; 12-12-2009 at 02:04 PM.
    home = hat.position;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to pass a matrix/array from main to a function
    By Inukami in forum C Programming
    Replies: 7
    Last Post: 12-09-2009, 09:03 PM
  2. windows console size
    By fkheng in forum C Programming
    Replies: 4
    Last Post: 07-06-2003, 03:21 PM
  3. Replies: 11
    Last Post: 03-25-2003, 05:13 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21