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. View Back Ground Color

View Back Ground Color

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

    I have an SDI application. I want to change the background of view.... I tried SetBkColor(RGB(255,0,255) in OnDraw(), OnPaint(), but no success... I tried OnCtColor(),,,, it also not works... Any Help?

    H 1 Reply Last reply
    0
    • A Ahmad99

      I have an SDI application. I want to change the background of view.... I tried SetBkColor(RGB(255,0,255) in OnDraw(), OnPaint(), but no success... I tried OnCtColor(),,,, it also not works... Any Help?

      H Offline
      H Offline
      HENDRIK R
      wrote on last edited by
      #2

      Try OnEraseBkgnd(). It's usually used to set the background of a view.

      A 1 Reply Last reply
      0
      • H HENDRIK R

        Try OnEraseBkgnd(). It's usually used to set the background of a view.

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

        No It not works It has a CDC pointer as a parametre. I created a brush of desired Color,,, and then i Select it pDC->SelectObject(&brush); But no Success!..

        H 1 Reply Last reply
        0
        • A Ahmad99

          No It not works It has a CDC pointer as a parametre. I created a brush of desired Color,,, and then i Select it pDC->SelectObject(&brush); But no Success!..

          H Offline
          H Offline
          HENDRIK R
          wrote on last edited by
          #4

          Here's an example taken from MSDN: BOOL CSampleView::OnEraseBkgnd(CDC* pDC) { // Set brush to desired background color. CBrush backBrush(RGB(255, 128, 128)); // Save old brush. CBrush* pOldBrush = pDC->SelectObject(&backBrush); CRect rect; pDC->GetClipBox(&rect); // Erase the area needed. pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY); pDC->SelectObject(pOldBrush); return TRUE; } If that doesn't work - which kind of view do you use?

          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