Solved

Changing mouse cursor

Posted on 1998-12-17
4
396 Views
Last Modified: 2013-11-20
I was wondering if anyone knows how to change the mouse cursor at run time?
I put  "SetCursor(m_hIcon);  in the mouse move event,  it works and everything, but it flashes, and it doesn't do it over command buttons, menus n'shit...   does anyone know how to make it changed for the program?
0
Comment
Question by:police1
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 30 total points
ID: 1326346
Your cursor change is undone by windows doing its default processing.

To change the cursor for a window you have to override OnSetCursor() and change the cursor in there, don't call the bas class if you've changed the cursor.

You should not(maybe cannot) change the cursor for every spot in your app. Each window that has the cursor over itself is responsible for the cursor's shape, unless a window has captured the cursor beforehand.

To change the cursor for your winodw without having to process OnSetCursor you can do it via the WNDCLASS. That structure can be modified in PreCreateWindow, via the CREATESTRUCT structure.
0
 

Author Comment

by:police1
ID: 1326347
Well, I'm not gonna accept this anwer yet...
the reason why.. is because it didn't work.  :(
I put in the onsetcursor thingy.. and took out the mouse move event... and put the set cursor in the onsetcursor... and it did nothing at all.

not even a bit.

Do you know where I could get an example for this?

0
 
LVL 3

Expert Comment

by:plaroche
ID: 1326348
You can check the doc with devstudio, there surely are samples that show how it works. Try a query for WM_SETCURSOR or OnSetCursor.

In the meantime here's an example from my app:
BOOL CGBarTime::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    switch(m_mouseRegion) {
    case DISP_CURRENT:
        SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE));
        return TRUE;

    case NONE:
        if( m_pInstInfo && m_pRuler && (m_editRegion == NONE) &&
            m_pInstInfo->CommandGet() == CInstInfo::CMD_STOP) {
            SetCursor(AfxGetApp()->LoadCursor(IDC_ZOOM));
        }
        return TRUE;
    }

      return CWnd::OnSetCursor(pWnd, nHitTest, message);
}



0
 

Author Comment

by:police1
ID: 1326349
Wooo
that worked  :)
thanx alot

btw, what program are you writting?
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 140
fizzArray  challenge 1 93
mapAB Challlenge 35 155
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 102
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.

792 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