class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL// Implementation
public:
void Move(CPoint cp);
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endifprotected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};void CMoveWindowView::OnMouseMove(UINT nFlags, CPoint point)
{
CMainFrame* pm = AfxGetApp()->m_pMainWnd ;
if(m_nStep == 1)
pm->Move(point);
CView::OnMouseMove(nFlags, point);
}void CMoveWindowView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_nStep = 0;
CView::OnRButtonDown(nFlags, point);
}如果按照这样做的话会在窗口随鼠标移动过程中出现窗口的闪动。请问各位朋友有没有什么好方法可以避免这种现象?谢谢。
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL// Implementation
public:
void Move(CPoint cp);
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endifprotected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};void CMoveWindowView::OnMouseMove(UINT nFlags, CPoint point)
{
CMainFrame* pm = AfxGetApp()->m_pMainWnd ;
if(m_nStep == 1)
pm->Move(point);
CView::OnMouseMove(nFlags, point);
}void CMoveWindowView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_nStep = 0;
CView::OnRButtonDown(nFlags, point);
}如果按照这样做的话会在窗口随鼠标移动过程中出现窗口的闪动。请问各位朋友有没有什么好方法可以避免这种现象?谢谢。
mailto:[email protected]方法如下
映射OnEraseBkgnd(CDC* pDC), return TRUE;
然后在OnPaint里自绘背景色,如下。BOOL CFTPServerMainDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
return CDialog::OnEraseBkgnd(pDC);
}void CFTPServerMainDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CMemDC MemDC(&dc);
CDC *pDC=NULL;
if(MemDC.m_bError) pDC=&dc;
else pDC=&MemDC; //设置背景色
CRect rectClient;
GetClientRect(rectClient);
CBrush brush(GetSysColor(COLOR_3DFACE));
pDC->SetBkMode(TRANSPARENT);
pDC->FillRect(rectClient, &brush);
brush.DeleteObject();
}