Solved

change background color of childview dynamically

Posted on 2003-11-14
2
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 50 total points
ID: 9753710
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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