Solved

color in a view

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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