::SetWindowPos 与 ::MoveWindow
按照网上的方法用双缓冲刷新一个WINDOW的背景..
BOOL CMoveRect::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
// CWnd::OnEraseBkgnd(pDC);
CRect rect;
this->GetClientRect(rect);
CBitmap bmpFace;
bmpFace.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
CBitmap* pOldBmp = NULL;
CDC MemDC;
MemDC.CreateCompatibleDC( pDC );
pOldBmp = MemDC.SelectObject(&bmpFace);
CBrush brush(RGB(23,255,58));
MemDC.FillRect(rect,&brush);
pDC->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBmp);
bmpFace.DeleteObject();
MemDC.DeleteDC();
return FALSE;
}
在VIEW中创建一个窗口..这个窗口用以上方法填充底色.并随MOUSE移动
1.用SetWindowPos 来移动..窗口闪个不停
void CTemp1View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
::SetWindowPos( m_MoveWindow.m_hWnd, NULL, point.x, point.y, 100, 100,SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOCOPYBITS );
CView::OnMouseMove(nFlags, point);
}
2. 把::SetWindowPos 改成 ::MoveWindow..就不闪了...
为什么呢?