Solved

Changing mouse cursor

Posted on 1998-12-17
4
365 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 94
maven archtype selection in eclipse 1 51
countEvens challenge 2 58
scoreUp challenge 14 48
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 …
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now