Link to home
Start Free TrialLog in
Avatar of mike_marquet
mike_marquet

asked on

How to change an application mouse cursor !

I have an MDI application.

How can I change the mouse cursor of the global application.

By default, the cursor is an arrow but I want to change it

I have try to use SetClassLong(m_hWnd, GCL_HCURSOR, hMyCursor), but works only for the owner view of the m_hWnd. That meens, that if I go to an other view, the cursor return to default.

Can someone help me !
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

I think you have to do that (SetClassLong) for each window class in your app.

The system automatically displays the class cursor (the cursor associated with the window to which the cursor is pointing).
Avatar of mike_marquet
mike_marquet

ASKER

I think there is an other solution but how ?

Doing this for each windows is to lot of works.
I don't know any other method.
I know it is crude but you will only have a few different window classes (OnCreate of each class?).
there are two methods
first one changes the cursor dynamically
second one changes it at the time of creation

1.
 BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
      {
            if ( m_ChangeCursor )
              {
                  ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
                  return TRUE;
              }

            return CView::OnSetCursor(pWnd, nHitTest, message);
      }
2.
 BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
      {
          cs.lpszClass = AfxRegisterWndClass(
            CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, // use any window styles
            AfxGetApp()->LoadStandardCursor(IDC_WAIT),
            (HBRUSH) (COLOR_WINDOW + 1));         // background brush

          return CView::PreCreateWindow(cs)
      }
I must do it dynamically but using OnSetCursor message is also a lot of work because I must do it for all views in my application (I know this method). But my question is how to change it for the global application using a simple method (1 function only, ex. : SetApplCursor which not exist).

If there is no other simple solution, then I must do such a work
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial