The WM_SETCURSOR message is sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured.
看清楚了,只要鼠标移动OnMouseMOve就会自动发送 WM_SETCURSOR从而触发OnSetCursor,因此在设计改变鼠标指针的程序时,一般不要在OnMouseMOve事件中调用SetCursor,容易引起指针闪烁。设置鼠标指针形状合理的方法是:
在OnMouseMove中使用一个变量记住各加载后的光标,然后在OnSetCursor调用SetCursor设置鼠标.
例如:
先在
void xx::OnMouseMove{
m_hCursor = LoadCursor(NULL,IDC_IBEAM); //想要添加的光标
}
然后在
BOOL xx::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
SetCursor(m_hCursor);
return TRUE;
}
装载这位前辈的博客:http://5902977.blog.51cto.com/5892977/1016307