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. question about font size

question about font size

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 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.
  • G Offline
    G Offline
    gucy
    wrote on last edited by
    #1

    i do the following to change the font size of my CEdit control.But it doesn't work well,Who can tell me what's the wrong BOOL CDlgBase::OnInitDialog() { CDialog::OnInitDialog(); CFont *m_Font; CFont m_newFont; LOGFONT m_lf; memset(&m_lf,0,sizeof(LOGFONT)); m_Font = GetFont(); m_Font->GetLogFont(&m_lf); CClientDC dc(this); m_lf.lfHeight = -MulDiv( 8,dc.GetDeviceCaps( LOGPIXELSY ), 72 ); m_newFont.CreateFontIndirect(&m_lf); m_edit.SetFont(&m_newFont); return true; } gucy

    E U 2 Replies Last reply
    0
    • G gucy

      i do the following to change the font size of my CEdit control.But it doesn't work well,Who can tell me what's the wrong BOOL CDlgBase::OnInitDialog() { CDialog::OnInitDialog(); CFont *m_Font; CFont m_newFont; LOGFONT m_lf; memset(&m_lf,0,sizeof(LOGFONT)); m_Font = GetFont(); m_Font->GetLogFont(&m_lf); CClientDC dc(this); m_lf.lfHeight = -MulDiv( 8,dc.GetDeviceCaps( LOGPIXELSY ), 72 ); m_newFont.CreateFontIndirect(&m_lf); m_edit.SetFont(&m_newFont); return true; } gucy

      E Offline
      E Offline
      Eugene Pustovoyt
      wrote on last edited by
      #2

      You're must CFont m_newFont move to the header file as global object Best regards, Eugene Pustovoyt

      G 1 Reply Last reply
      0
      • G gucy

        i do the following to change the font size of my CEdit control.But it doesn't work well,Who can tell me what's the wrong BOOL CDlgBase::OnInitDialog() { CDialog::OnInitDialog(); CFont *m_Font; CFont m_newFont; LOGFONT m_lf; memset(&m_lf,0,sizeof(LOGFONT)); m_Font = GetFont(); m_Font->GetLogFont(&m_lf); CClientDC dc(this); m_lf.lfHeight = -MulDiv( 8,dc.GetDeviceCaps( LOGPIXELSY ), 72 ); m_newFont.CreateFontIndirect(&m_lf); m_edit.SetFont(&m_newFont); return true; } gucy

        U Offline
        U Offline
        Uma Mahes
        wrote on last edited by
        #3

        your code is perfectly working for me. :)

        T 1 Reply Last reply
        0
        • E Eugene Pustovoyt

          You're must CFont m_newFont move to the header file as global object Best regards, Eugene Pustovoyt

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

          hi : After i move the CFont declaration out of the function,it works well. But what i wonder is that i have used these code int the function CMainFrame::OnCreate to change the edit control'size on the toolbar. i also declare the CFont as local vaiable and it works perfect. Why i must delare it as global variable here. gucy

          1 Reply Last reply
          0
          • U Uma Mahes

            your code is perfectly working for me. :)

            T Offline
            T Offline
            Toni78
            wrote on last edited by
            #5

            As Eugene Pustovoyt said, the font variable needs to be a global variable. It really doesn't matter if it works for you (no offense) or for anyone else. It won't work all the time. MSDN says that the font variable MUST be a global variable and I learned that the hard way. // Afterall, I realized that even my comment lines have bugs

            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