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. Form Background color change - Reg.

Form Background color change - Reg.

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
4 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.
  • P Offline
    P Offline
    Paulraj G
    wrote on last edited by
    #1

    Hi.. In CView application I am showing a dialog(Like toolbar/ Status bar). I have to change the dialog background color. I used the following code. But background color not changing. If i use this same in new dialog application the background color is changing.

    ON_WM_ERASEBKGND()

    BOOL CTech::OnEraseBkgnd(CDC* pDC)
    {
    CRect rect; GetClientRect(&rect);
    CBrush myBrush(RGB(255, 0, 255));
    // dialog background color
    CBrush *pOld = pDC->SelectObject(&myBrush);
    BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
    pDC->SelectObject(pOld);
    // restore old brush
    return bRes;
    }

    How to solve this problem. Any help will be appriciated.. Thanks...

    G.Paulraj

    L 1 Reply Last reply
    0
    • P Paulraj G

      Hi.. In CView application I am showing a dialog(Like toolbar/ Status bar). I have to change the dialog background color. I used the following code. But background color not changing. If i use this same in new dialog application the background color is changing.

      ON_WM_ERASEBKGND()

      BOOL CTech::OnEraseBkgnd(CDC* pDC)
      {
      CRect rect; GetClientRect(&rect);
      CBrush myBrush(RGB(255, 0, 255));
      // dialog background color
      CBrush *pOld = pDC->SelectObject(&myBrush);
      BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
      pDC->SelectObject(pOld);
      // restore old brush
      return bRes;
      }

      How to solve this problem. Any help will be appriciated.. Thanks...

      G.Paulraj

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I do not think that this is the message for the dialog's background repaint. Take a look at the WM_CTLCOLORDLG[^] notification.

      txtspeak is the realm of 9 year old children, not developers. Christian Graus

      P 1 Reply Last reply
      0
      • L Lost User

        I do not think that this is the message for the dialog's background repaint. Take a look at the WM_CTLCOLORDLG[^] notification.

        txtspeak is the realm of 9 year old children, not developers. Christian Graus

        P Offline
        P Offline
        Paulraj G
        wrote on last edited by
        #3

        It is working fine in form based applications...

        G.Paulraj

        L 1 Reply Last reply
        0
        • P Paulraj G

          It is working fine in form based applications...

          G.Paulraj

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Paulraj G wrote:

          It is working fine in form based applications...

          What has that to do with a Dialog? Did you follow the link I posted, and try using the methods suggested by Microsoft?

          txtspeak is the realm of 9 year old children, not developers. Christian Graus

          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