|
在鼠标移动事件中改变CWnd大小,大小改变时CWnd窗口会闪烁,
重载CWnd类的OnEraseBkgnd方法返回TRUE、重载CWnd 的 OnPaint使用双缓冲不能解决问题
在 CMFCApplication1Dlg 类中声明
MyWnd *m_pwnd;
CPoint m_firstpos;
成员
BOOL CMFCApplication1Dlg::OnInitDialog()
{
RECT rect;
rect.top = 0;
rect.left = 0;
rect.right = 1;
rect.bottom = 1;
m_pwnd = new CWnd;
BOOL b = m_pwnd->Create(NULL, NULL, WS_BORDER | WS_CHILD, rect, this, 123);
m_pwnd->SetParent(this);
m_pwnd->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
}
void CMFCApplication1Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
m_firstpos = point;
CDialogEx::OnLButtonDown(nFlags, point);
}
void CMFCApplication1Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
RECT rc;
rc.top = m_firstpos.y;
rc.left = m_firstpos.x;
rc.right = point.x - 2;
rc.bottom = point.y -2;
m_pwnd->MoveWindow(&rc);
m_pwnd->Invalidate(1);
m_pwnd->ShowWindow(SW_SHOW);
CDialogEx::OnMouseMove(nFlags, point);
} |
|