-
July 6th, 2006, 12:31 PM
#1
Paint back color of CScrollView derived class.
I am using a memory dc to do the drawing, therefore, I override OnEraseBkgnd(...) and return FALSE. In the Ondraw(...) function for my
CScrollView class, I attempt to repaint the background color to gray.
Why does it not get painted.
Code:
void CTaskPlan::OnDraw(CDC* pDC)
{
QBufferDC dc(pDC, SRCCOPY);
CRect rcClient;
GetClientRect(&rcClient);
dc.FillSolidRect(&rcClient, RGB(128,128,128));
m_Pages[0].OnDraw(&dc);
}
The page gets drawn so I know the dc is good. But the background color is not set.
Any ideas?
Mike B
-
July 6th, 2006, 01:26 PM
#2
Re: Paint back color of CScrollView derived class.
inside QBufferDC constructor?
select object brush
Kuphryn
-
July 6th, 2006, 01:33 PM
#3
Re: Paint back color of CScrollView derived class.
 Originally Posted by kuphryn
inside QBufferDC constructor?
select object brush
Kuphryn
Sheeesh, always something really dumb. I had to normalize rcClient CRect object. Whoops, forgot to add, also had to convert from device to logical units.
Mike B
Last edited by MikeB; July 6th, 2006 at 01:45 PM.
-
July 6th, 2006, 07:00 PM
#4
Re: Paint back color of CScrollView derived class.
Or you can add an handler fucntion into your view class <OnEraseBkgnd>
as under:
BOOL CMHSDProjectView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
// This code is added for the colored background of the document view
CBrush brNew(RGB(192,192,255)); //Creates a blue brush
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brNew);
CRect rc;
pDC->GetClipBox(rc); // Gets the co-ordinates of the client
// area to repaint.
pDC->PatBlt(0,0,rc.Width(),rc.Height(),PATCOPY);
// Repaints client area with current brush.
pDC->SelectObject(pOldBrush);
return TRUE; // Prevents the execution of return
// CView::OnEraseBkgnd(pDC) statement
return CView::OnEraseBkgnd(pDC);
}
Regards,
Bhushan.
-
July 6th, 2006, 09:33 PM
#5
Re: Paint back color of CScrollView derived class.
Use SetClassLong(m_hWnd, GCL_HBRBACKGROUND, (LONG)(HBRUSH)m_Brush)
in OnInitialUpdate or anywhere you want to set new color for view’s background.
Use your own CBrush object or any predefined system brushes (COLOR_xxx).
There are only 10 types of people in the world:
Those who understand binary and those who do not.
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
|