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. CFont problem...

CFont problem...

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 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.
  • R Offline
    R Offline
    Ruca
    wrote on last edited by
    #1

    Hi! I'm trying to use two diferent CFont objects to use in diferente CStatics, but one of them is never used, why does this happends, i did like : void CUnits_Sold::OnInitialUpdate() { CFormView::OnInitialUpdate(); //trata das fontes para os títulos CFont hFont; CFont hFontForm; hFont.CreateFont(40, 15, 0, 0, FW_BOLD ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet"); m_stCStatic.SetFont(&hFont); m_stCLabel.SetFont(&hFont); m_stCMachineName.SetFont(&hFont); m_stCTempo.SetFont(&hFont); m_stCTempo2.SetFont(&hFont); //cria a fonte para as letras de identificação do form hFontForm.CreateFont(200, 14, 0, 0, 0 ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet"); m_stCFormName.SetFont(&hFontForm); } This hfontform is not used and the m_stCFormName uses the hFont, what am I doing wrong? Thank you for your time Rui

    M 1 Reply Last reply
    0
    • R Ruca

      Hi! I'm trying to use two diferent CFont objects to use in diferente CStatics, but one of them is never used, why does this happends, i did like : void CUnits_Sold::OnInitialUpdate() { CFormView::OnInitialUpdate(); //trata das fontes para os títulos CFont hFont; CFont hFontForm; hFont.CreateFont(40, 15, 0, 0, FW_BOLD ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet"); m_stCStatic.SetFont(&hFont); m_stCLabel.SetFont(&hFont); m_stCMachineName.SetFont(&hFont); m_stCTempo.SetFont(&hFont); m_stCTempo2.SetFont(&hFont); //cria a fonte para as letras de identificação do form hFontForm.CreateFont(200, 14, 0, 0, 0 ,FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "MSTrebuchet"); m_stCFormName.SetFont(&hFontForm); } This hfontform is not used and the m_stCFormName uses the hFont, what am I doing wrong? Thank you for your time Rui

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      As soon as the CFont objects go out of scope, they are destructed. The CFont destructor destroys the GDI font objects. Make the CFont variables members of the view class. --Mike-- "Adventure. Excitement. A Jedi craves not these things."   -- Silent Bob 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm

      R 1 Reply Last reply
      0
      • M Michael Dunn

        As soon as the CFont objects go out of scope, they are destructed. The CFont destructor destroys the GDI font objects. Make the CFont variables members of the view class. --Mike-- "Adventure. Excitement. A Jedi craves not these things."   -- Silent Bob 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm

        R Offline
        R Offline
        Ruca
        wrote on last edited by
        #3

        Thank you Michael Dunn, it's working! Rui

        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