Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Current window font ?

Current window font ?

Scheduled Pinned Locked Moved Windows API
question
3 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vilius_m
    wrote on last edited by
    #1

    Hello, How do I get some window(control actually) font ? I tried to do this by using: HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 ); The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks Vilius

    H L 2 Replies Last reply
    0
    • V vilius_m

      Hello, How do I get some window(control actually) font ? I tried to do this by using: HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 ); The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks Vilius

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      The usual way is to send the window a WM_GETFONT message. However, if the control doesn't handle WM_GETFONT messages, you will not be able to get the font.

      Best wishes, Hans


      [Hans Dietrich Software]

      1 Reply Last reply
      0
      • V vilius_m

        Hello, How do I get some window(control actually) font ? I tried to do this by using: HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 ); The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks Vilius

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You need to be sure that the alternate font is currently selected into the device context; I just tried this code and it works correctly. It may well be that when you capture the window it is not currently in 'painting' mode, and thus does not have an active device context with a selected font.

        d@nish[^] has the answer.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups