Solved

color in a view

Posted on 1998-06-09
2
212 Views
Last Modified: 2013-11-20
How do I change the background color in a view? I overrode the OnPrepareDC function, and tried to do a
SetBKColor((255,0,0));   but it did not work.  However, it did place a black square on wherever the text should have been?

On a similar note, how do I change the textcolor?

Thanks in Advancew
0
Comment
Question by:smithc
[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 1

Accepted Solution

by:
motigust earned 50 total points
ID: 1316506
Try to ovveride the WM_ERASEBKGND message.

The function that will be called should look somthing like this:
(This example changes the BG to green)

BOOL CMyView::OnEraseBkgnd(CDC* pDC)
{
  CBrush Br(RGB(0x00,0xFF,0x00)); // green brush
  CRect rcBounds;
  pDC->GetClipBox(&rcBounds);
 
  CBrush* pOldBrush = pDC->SelectObject(&Br);
  pDC->PatBlt(rcBounds.left, rcBounds.top, rcBounds.Width(), rcBounds.Height(),PATCOPY);
  pDC->SelectObject(pOldBrush);
 
  return TRUE; // this means that we changed the BG
}


Have fun,
Moti.
0
 

Author Comment

by:smithc
ID: 1316507
Thanks.  It didn't work in the OnEraseBkground....but it did in the OnPrepareDC.

Thanks
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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.

624 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