我在一篇文章中看到用以下方法添加动态鼠标:
1.首先在类中增加成员变量m_hAniCursor,然后在构造函数中赋空值, void CSampleView::CSampleView()
{
m_hAniCursor = NULL;
}2.再利用LoadCursorFromFile()载入动态鼠标文件: void CSampleView::OnInitialUpdate()
{//推荐在OnInitialUpdate或OnInitialDialog
//中载入动态鼠标文件
...
if(m_hAniCursor == NULL)
m_hAniCursor = LoadCursorFromFile("d:\\path\\sample.ani");
...
}3.然后在需要改变鼠标的地方调用SetCursor()。推荐截取WM_SETCURSOR消息,然后修改OnSetCursor()函数。 BOOL CAboutDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
// TODO: Add your message handler code here and/or call default
if(m_hAniCursor!=NULL)
SetCursor(m_hAniCursor);
return TRUE;
//return CDialog::OnSetCursor(pWnd, nHitTest, message);
}但是照做之后,没有动态鼠标出现,请问这是什么原因?

解决方案 »

  1.   

    参考资料:
    给你的应用程序添加动态鼠标
    http://www.vckbase.com/document/viewdoc.asp?id=450
      

  2.   

    BOOL CMainFrame::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // return CFrameWnd::OnSetCursor(pWnd, nHitTest, message);
    SetCursor(hCursor); return true;
    }
      

  3.   

    BOOL CAboutDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // TODO: Add your message handler code here and/or call default
    if(m_hAniCursor!=NULL)
    SetCursor(m_hAniCursor);
    return TRUE;
    //return CDialog::OnSetCursor(pWnd, nHitTest, message);
    }
    其中CAboutDlg是否应该是CSampleView
      

  4.   

    我是在http://www.vckbase.com/document/viewdoc.asp?id=450看过这篇文章过做的,可是没有做成功.
    以上各位好像了都看过了,不知照做后有没有成功?
      

  5.   

    楼上这位大哥,我在各个类的OnSetCursor()中都试过,可是鼠标还是没有变过来!!
      

  6.   

    按常理应该是没有问题,(在CView::OnSetCursor()里设置)
    你调试一下你的LoadCursorFromFile("d:\\path\\sample.ani");函数调用有没有成功?如果这里调用成功的话,那绝对没有问题.