Solved

change background color of childview dynamically

Posted on 2003-11-14
2
296 Views
Last Modified: 2013-11-20
I'm new to MFC and I'm trying to dynamically change the background color of a childview.  I can set a color in the preCreateWindow(), but I don't know how to change the color dynamically.  
0
Comment
Question by:deetz623
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 50 total points
Comment Utility
Trap the WM_ERASEBKGND message and create a handler for it with the wizard.
Then in the function fill the background with the colour you want and return TRUE from the function,

eg.
BOOL CXyzView::OnEraseBkgnd(CDC* pDC)
{
      CRect rect;
      GetClientRect(&rect);
      pDC->FillSolidRect(&rect, RGB(255, 0,0,));
      
      //return CView::OnEraseBkgnd(pDC);
      return TRUE;
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now