Solved

color in a view

Posted on 1998-06-09
2
188 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
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. …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now