Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

color in a view

Posted on 1998-06-09
2
Medium Priority
?
215 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
2 Comments
 
LVL 1

Accepted Solution

by:
motigust earned 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

824 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