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 !
mike_marquetAsked:
Who is Participating?
 
AndyAinscowFreelance programmer / ConsultantCommented:
You have an MDI app
Use the SetClassLong call in the OnCreate of the following classes you have inherited
CMainFrame, CChildFrame, CView
Plus the OnInitDialog of any dialog classes you add.  By my counting that is 3 (4, 5) lines of code.  (I agree one line would be simpler).


ps. Personally I dislike apps that change the settings (albeit temporarily) of my system.   Talking as the end user.  I have customised my PC to display the cursors I want.  Why the **** does this exe not display them.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
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).
0
 
mike_marquetAuthor Commented:
I think there is an other solution but how ?

Doing this for each windows is to lot of works.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
AndyAinscowFreelance programmer / ConsultantCommented:
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?).
0
 
Amritpal SinghCommented:
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)
      }
0
 
mike_marquetAuthor Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.