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. Background color on Text Boxes and other controls

Background color on Text Boxes and other controls

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 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.
  • R Offline
    R Offline
    Reagan Conservative
    wrote on last edited by
    #1

    I have been able to change the background color on my Dialog box, but the background colors are still white on my text boxes and other controls. How does one change the background on those items? Thanks for your assistance.

    John P.

    S A H 3 Replies Last reply
    0
    • R Reagan Conservative

      I have been able to change the background color on my Dialog box, but the background colors are still white on my text boxes and other controls. How does one change the background on those items? Thanks for your assistance.

      John P.

      S Offline
      S Offline
      see me
      wrote on last edited by
      #2

      For edit box in onctlcolor OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if( CTLCOLOR_EDIT == nCtlColor ) { pDC->SetBkColor( RGB(250, 0, 0 )); }:) }

      Dream bigger... Do bigger...Expect smaller aji

      R 1 Reply Last reply
      0
      • R Reagan Conservative

        I have been able to change the background color on my Dialog box, but the background colors are still white on my text boxes and other controls. How does one change the background on those items? Thanks for your assistance.

        John P.

        A Offline
        A Offline
        anu_88
        wrote on last edited by
        #3

        In WM_CTLCOLOR message handler set background mode as transparent and return a null brush. This will make the background colour of the controls same as background colour of your dialog

        R 1 Reply Last reply
        0
        • R Reagan Conservative

          I have been able to change the background color on my Dialog box, but the background colors are still white on my text boxes and other controls. How does one change the background on those items? Thanks for your assistance.

          John P.

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

          See WM_CTLCOLOREDIT

          _**


          **_

          WhiteSky


          R 1 Reply Last reply
          0
          • S see me

            For edit box in onctlcolor OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if( CTLCOLOR_EDIT == nCtlColor ) { pDC->SetBkColor( RGB(250, 0, 0 )); }:) }

            Dream bigger... Do bigger...Expect smaller aji

            R Offline
            R Offline
            Reagan Conservative
            wrote on last edited by
            #5

            Thanks for the assistance!

            John P.

            1 Reply Last reply
            0
            • A anu_88

              In WM_CTLCOLOR message handler set background mode as transparent and return a null brush. This will make the background colour of the controls same as background colour of your dialog

              R Offline
              R Offline
              Reagan Conservative
              wrote on last edited by
              #6

              Thanks for the help!

              John P.

              1 Reply Last reply
              0
              • H Hamid Taebi

                See WM_CTLCOLOREDIT

                _**


                **_

                WhiteSky


                R Offline
                R Offline
                Reagan Conservative
                wrote on last edited by
                #7

                thanks WhiteSky.

                John P.

                H 1 Reply Last reply
                0
                • R Reagan Conservative

                  thanks WhiteSky.

                  John P.

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

                  You can use WM_CTLCOLOREDIT like this LRESULT CMyAnswer::OnCtlColorEdit(WPARAM wParam, LPARAM lParam) { HDC hdc = (HDC)wParam; SetBkMode(hdc,0); SetTextColor(hdc,TextColorEdit); // SetBkColor(hdc,RGB(53,97,200)); return (LRESULT)(m_pBrush->GetSafeHandle()); }

                  _**


                  **_

                  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