在一个一直有的函数中设置,比如放在OnMouseMove中

解决方案 »

  1.   

    delete the source one at PrecreateWindow() function,and set the one you wish at this function#define custom_classname "System!"
    BOOL CSystemView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: この位置で CREATESTRUCT cs を修正して Window クラスまたはスタイルを
    //  修正してください。
    if(!CView::PreCreateWindow(cs))
    return 0;
    WNDCLASS wndcls;
    HINSTANCE hinst=AfxGetInstanceHandle();
    if(!(::GetClassInfo(hinst,custom_classname,&wndcls)))
    {
    if(::GetClassInfo(hinst,cs.lpszClass ,&wndcls))
    {
    wndcls.lpszClassName=custom_classname;
    wndcls.style|=CS_OWNDC;
    wndcls.hCursor=LoadCursorFromFile("f:\\iu.ani");//this is the key
    wndcls.hCursor=NULL;
    wndcls.hbrBackground=::CreateSolidBrush(RGB(220,220,0));
    if(!AfxRegisterClass(&wndcls))
    AfxThrowResourceException();
    }
    else
    AfxThrowResourceException();
    }
    cs.lpszClass=custom_classname;
    return 1;
    // return CView::PreCreateWindow(cs);
    }
      

  2.   

    to:fingerfox(foxfinger) 这样我就改不回来了。我当然希望随时变换。
    to:sam1111   如果放在mousemove里,我觉得不如放在OnSetCursor()里。不过它们总是不停地执行,难道就不能设置一次,就一直保持直到我下一次改变它吗?
      

  3.   

    to chenzhou35(chenzhou35):
        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. 
        So you'd better register one WNDCLASS for permanence, or you must use SetCursor() frequently.