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. color the text of radio button

color the text of radio button

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
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.
  • V Offline
    V Offline
    vasmvr
    wrote on last edited by
    #1

    Hi all, i will thank in advance for your help. I want to color the text of radio button, using OnCtlColor but the color doesn't change. anyone know how i can color the text? this is a part of my Dialog box HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if( (pWnd->GetDlgCtrlID() == IDC_RADIO1) || (pWnd->GetDlgCtrlID() == IDC_RADIO2) ) { pDC->SetTextColor(((CEstoApp*)AfxGetApp())->GetSfondoTesti()); pDC->SetBkMode(TRANSPARENT); } return hbr; } Thanks to all

    P H 2 Replies Last reply
    0
    • V vasmvr

      Hi all, i will thank in advance for your help. I want to color the text of radio button, using OnCtlColor but the color doesn't change. anyone know how i can color the text? this is a part of my Dialog box HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if( (pWnd->GetDlgCtrlID() == IDC_RADIO1) || (pWnd->GetDlgCtrlID() == IDC_RADIO2) ) { pDC->SetTextColor(((CEstoApp*)AfxGetApp())->GetSfondoTesti()); pDC->SetBkMode(TRANSPARENT); } return hbr; } Thanks to all

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      Try returning brush of color you want.

      HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      {
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

      if( (pWnd->GetDlgCtrlID() == IDC_RADIO1) ||
      (pWnd->GetDlgCtrlID() == IDC_RADIO2) )
      {
      hbr = CreateSolidBrush(...);
      }

      return hbr;
      }

      Prasad Notifier using ATL | Operator new[],delete[][^]

      1 Reply Last reply
      0
      • V vasmvr

        Hi all, i will thank in advance for your help. I want to color the text of radio button, using OnCtlColor but the color doesn't change. anyone know how i can color the text? this is a part of my Dialog box HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if( (pWnd->GetDlgCtrlID() == IDC_RADIO1) || (pWnd->GetDlgCtrlID() == IDC_RADIO2) ) { pDC->SetTextColor(((CEstoApp*)AfxGetApp())->GetSfondoTesti()); pDC->SetBkMode(TRANSPARENT); } return hbr; } Thanks to all

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        This code is working

        HBRUSH CAnswer::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(53,97,220)); return hbr; }


        WhiteSky


        V 1 Reply Last reply
        0
        • H Hamid Taebi

          This code is working

          HBRUSH CAnswer::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(53,97,220)); return hbr; }


          WhiteSky


          V Offline
          V Offline
          vasmvr
          wrote on last edited by
          #4

          thank for your answer, in fact the code is working, maybe in my case is not working because i use a resource that implement XP STYLE and maybe this is why the code in my program is not working. thank a lot

          H 1 Reply Last reply
          0
          • V vasmvr

            thank for your answer, in fact the code is working, maybe in my case is not working because i use a resource that implement XP STYLE and maybe this is why the code in my program is not working. thank a lot

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Maybe I had a problem like this but with ComboBox:)


            WhiteSky


            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