Solved

change background color of childview dynamically

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 35
either24  challenge 19 101
scoreUp challenge 14 64
sumHeights  challenge 17 74
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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