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. change color [modified]

change color [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
7 Posts 5 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.
  • Y Offline
    Y Offline
    yogendra kaushik
    wrote on last edited by
    #1

    plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz..................... Please mail me -- modified at 8:34 Friday 16th June, 2006

    _ D H L 4 Replies Last reply
    0
    • Y yogendra kaushik

      plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz..................... Please mail me -- modified at 8:34 Friday 16th June, 2006

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

      In OnCtlColor function add this block of code : Define in the header file as follows in the public section: COLORREF m_color; HBRUSH m_brush;

      if (pWnd->GetDlgCtrlID () == IDC_EDIT1) 
      	{
                pDC->SetBkColor(m_color);
                hbr = m_brush;
              }
      	if (pWnd->GetDlgCtrlID () == IDC_EDIT2) 
      	{
                pDC->SetBkColor(m_color);
                hbr = m_brush;
              }
      

      Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_ -- modified at 8:18 Friday 16th June, 2006

      1 Reply Last reply
      0
      • Y yogendra kaushik

        plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz..................... Please mail me -- modified at 8:34 Friday 16th June, 2006

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

        HBRUSH CAnswerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); pDC->SetTextColor(RGB(54,97,200));//text //pDC->SetBkColor(RGB(0,0,0));//background return hbr; }_**


        **_

        whitesky


        Y 1 Reply Last reply
        0
        • Y yogendra kaushik

          plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz..................... Please mail me -- modified at 8:34 Friday 16th June, 2006

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Just respond to the WM_CTLCOLOREDIT message.


          "The largest fire starts but with the smallest spark." - David Crow

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • H Hamid Taebi

            HBRUSH CAnswerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); pDC->SetTextColor(RGB(54,97,200));//text //pDC->SetBkColor(RGB(0,0,0));//background return hbr; }_**


            **_

            whitesky


            Y Offline
            Y Offline
            yogendra kaushik
            wrote on last edited by
            #5

            THIS WILL WORK BUT HOW I CAN CHANGE THE COLOR OF EDIT CONTROL AS U TEL BKCOLOR IT WILL CHANGE ONLY TEXT BACKGROUND BUT SIDE OF TEXT DOES NOT CHANGE Please mail me

            H 1 Reply Last reply
            0
            • Y yogendra kaushik

              THIS WILL WORK BUT HOW I CAN CHANGE THE COLOR OF EDIT CONTROL AS U TEL BKCOLOR IT WILL CHANGE ONLY TEXT BACKGROUND BUT SIDE OF TEXT DOES NOT CHANGE Please mail me

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

              yes see DavidCrow answer its very good and for how to use WM_CTLCOLOREDIT see Here[^]maybe it is some helpful to you_**


              **_

              whitesky


              1 Reply Last reply
              0
              • Y yogendra kaushik

                plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz..................... Please mail me -- modified at 8:34 Friday 16th June, 2006

                L Offline
                L Offline
                Laxman Auti
                wrote on last edited by
                #7

                yogendra wrote:

                plz tel me how to change the color of text in a edit control or static control and also tem how to change color of edit control plz tem me some example (code to understabd is easy) plz.....................

                Better way to Subclass both the Controls you can do whatever you want and use those classes. Following link directs you for subclassing Extended Edit and Static controls[^] Knock out 't' from can't, You can if you think you can :cool:

                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