下面是 这个问题的 解决办法:
/
// CFormView 在改变大小时,控件闪烁的问题
//#define VIEW_NO_BORDER
BOOL CSizingFormViewView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
#ifdef VIEW_NO_BORDER
cs.style &= ~WS_BORDER;// no border
#endif
return CFormView::PreCreateWindow(cs);
}
//
void CSizingFormViewView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// get size ,
CRect rc;
GetWindowRect(&rc);
rc.OffsetRect(-rc.left,-rc.top);
#ifndef VIEW_NO_BORDER
rc.OffsetRect(-2,-2);// offset -2,-2
#endif
// Create a compatible memory DC
CDC memDC;
memDC.CreateCompatibleDC(&dc);
// Select a compatible bitmap into the memory DC
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( &dc, rc.Width(), rc.Height());
HBITMAP oldBmp=(HBITMAP)memDC.SelectObject(&bitmap);
// Erase bkg
memDC.FillSolidRect(&rc,GetSysColor(COLOR_MENU));// RGB(210,210,210));
// Let the dialog draw everything into memDC.
SendMessage(WM_PRINT,(WPARAM)memDC.m_hDC,
(LPARAM)(PRF_CHILDREN | PRF_CLIENT ));//| PRF_NONCLIENT | PRF_ERASEBKGND | PRF_OWNED));
// copy to CB for checking
#ifdef TEST
memDC.SelectObject(oldBmp);
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP,bitmap);
CloseClipboard();
oldBmp=(HBITMAP)memDC.SelectObject(&bitmap);
#endif
dc.BitBlt(rc.left,rc.top, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
// set back
memDC.SelectObject(oldBmp);
// free
DeleteObject(bitmap.m_hObject);
DeleteObject(memDC);
// do not draw all Ctls !
#if 1
UINT id=0;
CWnd *pWnd=0;
//
pWnd=GetDlgItem(IDC_BUTTON1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_BUTTON2);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_GROUP);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_RADIO1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_RADIO2);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_STATIC1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_PICTURE);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_EDIT1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
#endif
// CFormView::OnPaint();
}
BOOL CSizingFormViewView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
// return CFormView::OnEraseBkgnd(pDC);
}
/