Solved

How do I set the background color of a CPropertyPage

Posted on 2006-06-11
6
712 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 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

689 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