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. C / C++ / MFC
  4. How do I know which font is used in dialog box

How do I know which font is used in dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 Posts 3 Posters 0 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.
  • I Offline
    I Offline
    IlanTal
    wrote on last edited by
    #1

    I would expect that if I use: CClientDC dc(this); inside the code for a dialog box it would pick up the font used for that dialog box. In fact, it doesn't. I had to add: currFont.CreatePointFont(80, "MS Sans Serif", &dc); oldFont = dc.SelectObject(&currFont); and then it measured the text extent correctly. (I got the font name and size from the dialog template.) Clearly, it won't change unless I change it in the project, but I am curious to know how to pick up the information "automatically". Any suggestions? Thanks, Ilan

    G 1 Reply Last reply
    0
    • I IlanTal

      I would expect that if I use: CClientDC dc(this); inside the code for a dialog box it would pick up the font used for that dialog box. In fact, it doesn't. I had to add: currFont.CreatePointFont(80, "MS Sans Serif", &dc); oldFont = dc.SelectObject(&currFont); and then it measured the text extent correctly. (I got the font name and size from the dialog template.) Clearly, it won't change unless I change it in the project, but I am curious to know how to pick up the information "automatically". Any suggestions? Thanks, Ilan

      G Offline
      G Offline
      grigsoft
      wrote on last edited by
      #2

      dc.SelectObject(GetFont()); ? Igor Green http://www.grigsoft.com/ - files and folders comparison tools

      I C 2 Replies Last reply
      0
      • G grigsoft

        dc.SelectObject(GetFont()); ? Igor Green http://www.grigsoft.com/ - files and folders comparison tools

        I Offline
        I Offline
        IlanTal
        wrote on last edited by
        #3

        Thanks. I didn't think it was that simple. It must be internally this.GetFont(), otherwise I don't know how it could figure out which font I want. In any case, it works.... Ilan

        G 1 Reply Last reply
        0
        • I IlanTal

          Thanks. I didn't think it was that simple. It must be internally this.GetFont(), otherwise I don't know how it could figure out which font I want. In any case, it works.... Ilan

          G Offline
          G Offline
          grigsoft
          wrote on last edited by
          #4

          You are right - CWnd::GetFont() returns current font for window. This font is not selected automatically in compatible DC on creation. Igor Green http://www.grigsoft.com/ - files and folders comparison tools

          1 Reply Last reply
          0
          • G grigsoft

            dc.SelectObject(GetFont()); ? Igor Green http://www.grigsoft.com/ - files and folders comparison tools

            C Offline
            C Offline
            cmk
            wrote on last edited by
            #5

            As an aside, i ran into this earlier this week in a WinCE (PocketPC 2002) app i was working on. I found that calling CWnd::GetFont() for a CDialog window always returned NULL. Turns out this is expected (from MSDN WM_GETFONT for WinCE): The WM_GETFONT message does not return a font handle if the message is sent to a dialog box created by the DialogBoxParam, DialogBoxIndirectParam, CreateDialogParam, or CreateDialogIndirectParam functions. ...cmk Save the whales - collect the whole set

            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