Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing mouse cursor

Posted on 1998-12-17
4
Medium Priority
?
426 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 120 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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