为了不发生光标闪烁,可以使用这种方法:
1、重载PreCreateWindow()函数,但是不指定要使用的鼠标光标,而是使用NULL,这样就防止Windows或
MFC针对鼠标指针作任何操作。
BOOL CGameView::PreCreateWindow(CREATESTRUCT& cs)
{
//创建自己的窗口类,窗口不设置光标,以便根据需要进行设置
if(cs.lpszClass==NULL)
cs.lpszClass=AfxRegisterWndClass(CS_DBLCLKS);
return CView::PreCreateWindow(cs);
}
2、OnMouseMove()函数中设置光标
void CGameView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame *frm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
frm->SetMousePosition(point.x,point.y);
int cursortype=frm->GetCursorType();
if(cursortype==cursorhand)
::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_HAND));
else if(cursortype==cursorno)
::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_NO));
else
::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ARROW));
CView::OnMouseMove(nFlags, point);
}