改变光标的时机和WM_SETCURSOR消息的原理??
改变光标:
1。改变整个程序的光标:在CMyView::PreCreateWindow()中对cs进行改 造,如:
cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW,AfxGetApp()->LoadStandardCursor(IDC_UPARROW), ::CreateSolidBrush(RGB(255,122,0)));
我有试验成功。
2.重载CMyView::OnSetCursor()
其内容譬如:
BOOL CScribbleView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
if( 当前光标在客户区 )
{
m_hCursor = AfxGetApp() ->LoadCursor( IDI_DiamondCursor );
::SetCursor(m_hCursor );
return true; //自已设置光标为何这里要返回true?
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
而且这样之后在光标移出客户区然后 再移进来时就恢复系统默认光标了,Why?是否与我的第4个问题有关?
3. WM_SETCURSOR消息是谁在何时触发?
比如我不在此消息中变更光标,而在OnMouseMove()中变更光标,可否?
但我试验的结果似乎没有效。
有人说:
OnMouseMove中可以实现,不过还需要SetCapture,ReleaseCapture,当进入View窗口时ReleaseCapture,移出时SetCapture
4.MSDN上有这么一段话:
If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.
我不知到哪里去把谁"set to NULL"?
谢谢!