Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting form view background color

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
Hey guys, real quick question, how do I change the backgound color when I choose CFormView as my base class? Also, how can I change the color of any control, like a static text or list box? Can I? I can change the background color of my text, but not my default view, it is just boring gray. Thanks,

CJB
 
The way I found was to edit the "OnCtlColor" of my view in the following way:

HBRUSH CMyClassView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// this is what was there before:
//HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
//And now my code:
CBrush brush;
brush.CreateSolidBrush(RGB(0, 128, 0));
// TODO: Return a different brush if the default is not desired
return brush;
// return NULL;
}

That way my background was a somewhat dark green. However, I *think* it worked only in win 9x, not win NT (it has been a while since I tested my program on windows NT). Can anyone confirm that? And maybe provide a way around that problem?

Vincent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top