Re: Problem with painting when using CScrollView::SetScaleToFitSize()
Sorry forgot to mention OnEraseBkgnd() override
BOOL COVDView::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
//return CScrollView::OnEraseBkgnd(pDC);
}
"mike" <nospamplease.com> wrote in message
news:elbOEJuJIHA.484@TK2MSFTNGP06.phx.gbl...
I am trying to us SetScaleToFitSize() to scale the image. If I draw
directly onto pDC the drawing
works but I get flicker. I am trying to use a custom CMemDC class that
normally works ok but with
SetScaleToFitSize() does not work. Neither the background nor white fill
area are being painted.
Can someone help?
thanks
void COVDView::OnDraw(CDC* pDC)
{
CRect client, lp;
GetClientRect( &client );
lp = client;
pDC->DPtoLP( &lp ); // Convert to logical coord
#if 1
/* Custom class to create a memory dc for drawing */
CMemDC dc( *pDC, lp.Width(), lp.Height() ); // lp.Width() and lp.Height()
== 6000 in debugger
dc.FillRect( &lp, &m_brBackGnd ); // gray backgnd
/* Fill area 600 wide and 5900 high (white) */
CRect rect( 0,0, 600, 5900 );
dc.FillSolidRect( &rect, RGB(255,255,255) );
/* Have tried all of these */
pDC->BitBlt( 0,0, lp.Width(), lp.Height(), &dc, 0,0, SRCCOPY );
// pDC->StretchBlt( 0,0, lp.Width(), lp.Height(), &dc, 0,0, lp.Width(),
lp.Height(), SRCCOPY );
// pDC->StretchBlt( 0,0, client.Width(), client.Height(), &dc, 0,0,
lp.Width(), lp.Height(), SRCCOPY );
#else
/* This works but get flicker */
pDC->FillRect( &lp, &m_brBackGnd ); // gray backgnd
CRect rect( 0,0, 600, 6900 );
pDC->FillSolidRect( &rect, RGB(255,255,255) );
#endif
}
void COVDView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal(6000,6000);
GetParentFrame()->RecalcLayout();
SetScaleToFitSize(sizeTotal);
}
void COVDView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
if ( cx && cy )
SetScaleToFitSize( CSize(6000, 6000));
}