改变光标的时机和WM_SETCURSOR消息的原理??

wangyangcheng wangyangcheng 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
改变光标:
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"?

谢谢!

...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
wangyangcheng
VC/MFC 16,550 成员 421,606 内容