?
Solved

How do I set the background color of a CPropertyPage

Posted on 2006-06-11
6
Medium Priority
?
725 Views
Last Modified: 2013-11-20
The title sums up my problem.  I have a tab control and each tab displays a different property page.  I need to be able to set the page color on tab selection.
Also, I've seen use of the OnCtrlClr method and was wondering if this when the page color is changed.

Thanks for your help.
0
Comment
Question by:alexatsearidge
[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
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16882974
you may put code like following on your WM_ERASEBACKGROUND handler :

::OnEraseBkgnd(CDC *pDC)
{
  CRect rect;
  GetClientRect(&rect);
  CBrush myBrush(RGB(255,0,0)); // Solid RED for instance
  CBrush *pOld = pDC->SelectObject(&myBrush);
  BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
  pDC->SelectObject(pOld); // Have to restore old brush
  return bRes;
}

-MAHESH
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 1500 total points
ID: 16883236
mahesh is correct in handling the WM_ERASEBKGND message, unfortunately the code sample contained mistakes.

CMyPage::OnEraseBkgnd(CDC *pDC)
{
  CRect rect;
  GetClientRect(&rect);
  pDC->FillSolidRect(RGB(255, 0, 0));  //Fill the background with red for example

  //return TRUE to inform the system you have redrawn the background yourself.
  return TRUE;
}
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 16883260
Sorry - the PatBlt ought to work even without a bitmap or bitmapped brush, treat my comment as an alternative for a solid colour.
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 16883266
I'm not having a good morning so far

pDC->FillSolidRect(RGB(255, 0, 0));  //Fill the background with red for example

should be

pDC->FillSolidRect(&rect, RGB(255, 0, 0));  //Fill the rectangle (background area) with red for example
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16883281
Well you may use anyone PatBlt() or FillSolidRect()
In my code pattern built is used to copy pattern to destination rectangle to make it solid fill.. which works.

-MAHESH
0
 

Author Comment

by:alexatsearidge
ID: 16885748
Thanks guys for all the help.  Really appreciate it.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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