Solved

Changing mouse cursor

Posted on 1998-12-17
4
416 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
[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
  • 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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

624 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