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. Set the font for text

Set the font for text

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelp
6 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.
  • M Offline
    M Offline
    MKC002
    wrote on last edited by
    #1

    I am trying to set the font for radio button using below code in my project but font does not set. Font and color does not set for text on radio button. I have a dialog base application (MFC), at dialog there are some radio buttons In dialog class, Oninitdialog() i use CFont* pFont = GetDlgItem( IDC_RADIO1 )->GetFont(); LOGFONT LogFont = { 0 }; pFont->GetLogFont( &LogFont ); LogFont.lfItalic = TRUE; LogFont.lfWidth = 9; LogFont.lfHeight = 12; LogFont.lfWeight = FW_BOLD; memcpy(LogFont.lfFaceName,"Verdana",7); m_StaticFont.CreateFontIndirect( &LogFont ); GetDlgItem( IDC_RADIO1 )->SetFont( &m_StaticFont ); in header file CFont m_StaticFont; To set the color for text on radio button, i use OnCtlColor (WM_CTLCOLOR) HBRUSH CtestxmlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { /// if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(255,0,0)); //// } But when i use above code in a test program it works. Please suggest what's wrong. I have debug my project and found OnCtlColor calls and it set the text color also. Please help.

    _ 1 Reply Last reply
    0
    • M MKC002

      I am trying to set the font for radio button using below code in my project but font does not set. Font and color does not set for text on radio button. I have a dialog base application (MFC), at dialog there are some radio buttons In dialog class, Oninitdialog() i use CFont* pFont = GetDlgItem( IDC_RADIO1 )->GetFont(); LOGFONT LogFont = { 0 }; pFont->GetLogFont( &LogFont ); LogFont.lfItalic = TRUE; LogFont.lfWidth = 9; LogFont.lfHeight = 12; LogFont.lfWeight = FW_BOLD; memcpy(LogFont.lfFaceName,"Verdana",7); m_StaticFont.CreateFontIndirect( &LogFont ); GetDlgItem( IDC_RADIO1 )->SetFont( &m_StaticFont ); in header file CFont m_StaticFont; To set the color for text on radio button, i use OnCtlColor (WM_CTLCOLOR) HBRUSH CtestxmlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { /// if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(255,0,0)); //// } But when i use above code in a test program it works. Please suggest what's wrong. I have debug my project and found OnCtlColor calls and it set the text color also. Please help.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      How is this test program different from the dialog based program that you mentioned first?

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++)

      Polymorphism in C

      M 1 Reply Last reply
      0
      • _ _Superman_

        How is this test program different from the dialog based program that you mentioned first?

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        M Offline
        M Offline
        MKC002
        wrote on last edited by
        #3

        Both are dialog based applications. Test program contains only one radio button. In main program there are lot of controls and work against them

        _ 1 Reply Last reply
        0
        • M MKC002

          Both are dialog based applications. Test program contains only one radio button. In main program there are lot of controls and work against them

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.

          «_Superman_»  _I love work. It gives me something to do between weekends.

          _Microsoft MVP (Visual C++)

          Polymorphism in C

          M 2 Replies Last reply
          0
          • _ _Superman_

            As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.

            «_Superman_»  _I love work. It gives me something to do between weekends.

            _Microsoft MVP (Visual C++)

            Polymorphism in C

            M Offline
            M Offline
            MKC002
            wrote on last edited by
            #5

            The font is set but text color is not set in first program. This is the problem with radio buttons. If i add a new radio button then also text color is not set. But for static control the text color is set. It means something needs to be supported for radio button

            1 Reply Last reply
            0
            • _ _Superman_

              As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.

              «_Superman_»  _I love work. It gives me something to do between weekends.

              _Microsoft MVP (Visual C++)

              Polymorphism in C

              M Offline
              M Offline
              MKC002
              wrote on last edited by
              #6

              I found the reason why.I am using XP theme. Below url also says that http://www.go4expert.com/forums/showthread.php?t=16457&page=2 If i remove xp theme then color is set for radio text. Is there any solution for that problem.It's require for me to use XP theme. XP theme

              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <assembly
              xmlns="urn:schemas-microsoft-com:asm.v1"
              manifestVersion="1.0">
              <assemblyIdentity
              processorArchitecture="x86"
              version="5.1.0.0"
              type="win32"
              name="appname.exe"/>
              <description>appname</description>
              <dependency>
              <dependentAssembly>
              <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              publicKeyToken="6595b64144ccf1df"
              language="*"
              processorArchitecture="x86"/>
              </dependentAssembly>
              </dependency>
              </assembly>

              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