Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to change an application mouse cursor !

Posted on 2004-10-29
7
Medium Priority
?
155 Views
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 !
0
Comment
Question by:mike_marquet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
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).
0
 

Author Comment

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

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

Expert Comment

by:AndyAinscow
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?).
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

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

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
 

Author Comment

by:mike_marquet
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
0
 
LVL 45

Accepted Solution

by:
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.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

609 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