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. Changing Background color and Static Control background color.

Changing Background color and Static Control background color.

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

    Hi all, i m using this.

    1. declare it in header file.
    protected:
    CBrush m_brush;

    1. now on OnInitDialg()
      m_brush.CreateSolidBrush(RGB(245, 245, 245)); // color white brush

    3.now on OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    return m_brush;

    but here edit contol also colored with this color. please tell me how can i change Back ground color of dialog box and back ground color of static control.

    To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

    A C 2 Replies Last reply
    0
    • L Le rner

      Hi all, i m using this.

      1. declare it in header file.
      protected:
      CBrush m_brush;

      1. now on OnInitDialg()
        m_brush.CreateSolidBrush(RGB(245, 245, 245)); // color white brush

      3.now on OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      return m_brush;

      but here edit contol also colored with this color. please tell me how can i change Back ground color of dialog box and back ground color of static control.

      To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

      A Offline
      A Offline
      ATM CodeProject
      wrote on last edited by
      #2

      Hi, Create a class for the control, then return the brush in OnCtlColor()(in the new class).Just try it iam not sure about the result.

      1 Reply Last reply
      0
      • L Le rner

        Hi all, i m using this.

        1. declare it in header file.
        protected:
        CBrush m_brush;

        1. now on OnInitDialg()
          m_brush.CreateSolidBrush(RGB(245, 245, 245)); // color white brush

        3.now on OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
        return m_brush;

        but here edit contol also colored with this color. please tell me how can i change Back ground color of dialog box and back ground color of static control.

        To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        If you read here[^], you find WM_CTLCOLORDLG[^] and WM_CTLCOLORSTATIC[^], maybe try handling these messages instead of WM_CTLCOLOR, aside of that, the documentation also states this for WM_CTLCOLOR: lParam A handle to a child window (control). This is the handle of the control asking for the color information, you could use that to filter out the controls you wish to change the background color.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        L 1 Reply Last reply
        0
        • C Code o mat

          If you read here[^], you find WM_CTLCOLORDLG[^] and WM_CTLCOLORSTATIC[^], maybe try handling these messages instead of WM_CTLCOLOR, aside of that, the documentation also states this for WM_CTLCOLOR: lParam A handle to a child window (control). This is the handle of the control asking for the color information, you could use that to filter out the controls you wish to change the background color.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          L Offline
          L Offline
          Le rner
          wrote on last edited by
          #4

          Thanks, please tell how can i color the background of formview.

          To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

          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