Home > Back-end >  MFC redraw background double-buffering changes window window control shine
MFC redraw background double-buffering changes window window control shine

Time:09-18

Solution is introduced:
MFC engineering, Dlg m_iImage a CImage variables in the class, when the constructor to Load a. JPG images, local background picture for Dlg
Dlg and some other control at the same time, I use the image in OnEraseBkgnd redraw the background, set up the invalid area in the OnSize
After the program is running basic can not achieve, but in the continuous rapid drag window Button Edit controls, such as would occasionally flashing
(note: the background image is stretched)
Also want to ask next m_iImage. StretchBlt (pDC - & gt; M_hDC,... ); This statement is not double buffer?

The following is the code:
 
//the constructor to load the local JPG images (redundant removes)
CMFCApplicationDlg: : CMFCApplicationDlg (pParent/*=NULL CWnd * */) : m_iImage. Load "f:/01. JPG" (L) {}

//redraw background
BOOL CMFCApplicationDlg: : OnEraseBkgnd (pDC) CDC * {
The static CRect the rect.
GetClientRect (the rect);
//set the stretching mode
SetStretchBltMode (pDC - & gt; M_hDC, COLORONCOLOR);
//the image size is 1440 * 900
M_iImage. StretchBlt (pDC - & gt; M_hDC, 0, 0, the rect. Width (), the rect. Height (), 0,0,1440,900);
Return TRUE;
}
//setting area when change the window size
Void CMFCApplicationDlg: : OnSize (UINT nType, cx, int int cy) {
CDialogEx: : OnSize (cx, nType, cy);
//set the invalid area, otherwise after drawing window background flowers screen
Invalidate (TRUE);
//this statement whether feel little instantly refresh will appear
UpdateWindow ();
}

Welcome to the great god message, points out the problem.
I wish you all in advance happy New Year!

  • Related