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. Dinamicaly changing window font

Dinamicaly changing window font

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
3 Posts 3 Posters 1 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.
  • G Offline
    G Offline
    Goran Dodig
    wrote on last edited by
    #1

    Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran

    A B 2 Replies Last reply
    0
    • G Goran Dodig

      Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran

      A Offline
      A Offline
      Alex Gorev
      wrote on last edited by
      #2

      Hi! You need to send the WM_SETFONT message to the window. See MSDN for more details... Regards, Alex Gorev, Dundas Software.

      1 Reply Last reply
      0
      • G Goran Dodig

        Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Here is sample for dialog.. // get dialog font and create thin variation for control contents HFONT hFont = (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0L); if( hFont ){ LOGFONT lf; ::GetObject(hFont, sizeof(LOGFONT), &lf); lf.lfWeight = FW_LIGHT; // check for attached font object already existing if( m_cfFont.m_hObject || m_cfFont.CreateFontIndirect(&lf) ){ // if supposed to set the thin font if( m_bThinFont ){ OnSetFont((CFont *)&m_cfFont); } } } void CGCDialog::OnSetFont(CFont *pFont) { HWND hWndChild = ::GetWindow(GetSafeHwnd(), GW_CHILD); while( hWndChild ){ CWnd::FromHandle(hWndChild)->SetFont(pFont); hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT); } }

        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