Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

color in a view

Posted on 1998-06-09
2
Medium Priority
?
214 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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: 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…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 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