How to change an application mouse cursor !

Posted on 2004-10-29
Medium Priority
Last Modified: 2013-11-20
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 !
Question by:mike_marquet
  • 3
  • 2
LVL 45

Expert Comment

ID: 12444723
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).

Author Comment

ID: 12445016
I think there is an other solution but how ?

Doing this for each windows is to lot of works.
LVL 45

Expert Comment

ID: 12445402
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?).
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.


Expert Comment

by:Amritpal Singh
ID: 12451000
there are two methods
first one changes the cursor dynamically
second one changes it at the time of creation

 BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
            if ( m_ChangeCursor )
                  return TRUE;

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

          return CView::PreCreateWindow(cs)

Author Comment

ID: 12481516
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
LVL 45

Accepted Solution

AndyAinscow earned 150 total points
ID: 12481582
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.

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question