Solved

change background color of childview dynamically

Posted on 2003-11-14
2
298 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 135
Perl Awk Need Help 3 116
substring method in java 1 116
sum67 challenge 35 97
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 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