nav-left cat-right
cat-right
Blog > Blog > C++ > MFC > Flicker Free example with CStatic Control

Flicker Free example with CStatic Control

Flicker Free drawing

It works very similar to the description of Flicker Free example with dialog.

The main point are to overload ON_WM_ERASEBKGND(), Invalidate the Window Area and paint in OnPaint with the class CMemDC.

Here however one has to make sure that there is no ON_WM_ERASEBKGND() in the Parent Dialog.

Resizing of Images

In this project the facility of CMemDC to scale the data to be shown is used:
void CGraphCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting	
 
	CRect (rc_dest);
	rc_dest=GetSize();
 
	CRect (rc_source);
	rc_source=GetPlotDataSize();
 
	CMemDC pDC(&dc,&rc_source, &rc_dest); // Double Buffering
	PlotToDC(& pDC);
}
 
CRect CGraphCtrl::GetSize()
{
	CRect rc;
	GetClientRect(rc);		
	return rc;
}
 
CRect CGraphCtrl::GetPlotDataSize()
{
	CRect rc;
	rc.left=0;		
	rc.top=0;
	rc.right=m_PixelNumberX;
	rc.bottom=m_PixelNumberY;		
	return rc;
}

Pages: 1 2 3

Leave a Reply

Spam Protection by WP-SpamFree