运行时改动CStatic的光标最简单的方法应该是什么?1。OnSetCursor;可行
2。SetCursor()为什么不行?既然不行,它是做什么用的?
3。如何查找MFC的源代码?

解决方案 »

  1.   

    HCURSOR hCursor;
    hCursor = AfxGetApp() -> LoadCursor(IDC_CURSOR1);
    SetCursor(hCursor);试试,绝对可行,我过的,效果很好
      

  2.   

    Example
    CStatic myStatic;// Create a child icon static control.
    myStatic.Create(_T("my static"), 
       WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), 
       pParentWnd);// Set the image of the static control to be the system arrow 
    // and small hourglass cursor.
    myStatic.SetCursor( ::LoadCursor(NULL, IDC_APPSTARTING) );
      

  3.   

    查找MFC源码?
    设个断点,跟踪进去。(进不去就是没有吧)
      

  4.   

    找MFC源码是为了学习和研究。我想知道具体的一个类到底定义在哪个文件,又实现在哪个文件。
      

  5.   

    xundeng(寻灯) ,c0der() 两位的代码我全试了。还是不行。我的CMyStatic从CStatic派生,有一个Initial(...)方法,在对话框的OnInitDialog()里调用。我只有等Initial传入参数以后才能确定采用哪个光标。另外,我还重载了PreSubclassWindow() 和OnLButtonDown()。我想在Initial调用SetCursor()直接解决,不行。我试过,只能重载OnSetCursor(...)才行。BOOL CMyStatic::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)

    HCURSOR hc;
    UINT nID = m_IsVertical ? IDC_CUR_SPLVER : IDC_CUR_SPLHOR;
    hc = AfxGetApp() ->LoadCursor(nID);
    if(hc != NULL)
        ::SetCursor(hc);
             return TRUE;
    }就是不知道为什么。太郁闷!希望大家继续帮忙!
      

  6.   

    This function establishes the cursor shape.HCURSOR SetCursor(
      HCURSOR hCursor
    );
    Parameters
    hCursor 
    [in] Handle to the cursor. The cursor must have been created by the CreateCursor or loaded by the LoadCursor or LoadImage function. If this parameter is NULL, the cursor is removed from the screen. 
    The width and height of the cursor must be the values returned by the GetSystemMetrics function for SM_CXCURSOR and SM_CYCURSOR. Return Values
    The handle to the previous cursor indicates success. NULL indicates that there was no previous cursor.Res
    Use Cursor.lib when targeting a platform that does not support mouse cursors. The only cursor this component library supports is the wait cursor. Use the following code to set the wait cursor.SetCursor(LoadCursor(NULL, IDC_WAIT));
    Use Mcursor.lib when targeting a platform that does support mouse cursors. This library does not support color cursors.If SetCursor is called after CreateCursor creates a zero dimension cursor, it still shows the old cursor, not the new cursor.The cursor is set only if the new cursor is different from the previous cursor; otherwise, the function returns immediately. The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window. 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. The cursor is not shown on the screen if the internal cursor display count is less than zero. This occurs if the application uses the ShowCursor function to hide the cursor more times than to show the cursor.