|
-
April 21st, 1999, 05:40 PM
#1
Painting the background...
In my SDI application, when it comes up, I want to paint the background
.
I tried using SetBkColor (RGB(....)) in WM_PAINT handler but didn't seem to work. Any clue how can I get this done?
-
April 21st, 1999, 07:31 PM
#2
Re: Painting the background...
There are two way to paint a window with a solid color.
1) handle erase background (WM_ERASEBKGND)
2) handle paint (WM_PAINT)
In both cases, you need to get the rectangle of the window and do a fill rect.
void CSomeWnd::OnPaint() (or int CSomeWnd::OnEraseBkgnd())
{
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.FillRect(&rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
}
If you want to use a color that is not available from GetStockObject, you have to create you own brush like the following and use it in place of GetStockObject.
CBrush brush(RGB(r,g,b));
(I don't have the documentation with me, so the function parameters maybe a little bit off, check the online help for sure)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|