Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem setting the mouse cursor on a view

problem setting the mouse cursor on a view

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Morden
    wrote on last edited by
    #1

    Hi, I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views. I've got the following code in the view: BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { ::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor))); return TRUE; //Handled } I'm doing it this way since I've disabled the class cursor with: ::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL); and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.] However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after. I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear. If anyone can shed any light on this, your help will be much appreciated.

    C 1 Reply Last reply
    0
    • M Mr Morden

      Hi, I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views. I've got the following code in the view: BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { ::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor))); return TRUE; //Handled } I'm doing it this way since I've disabled the class cursor with: ::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL); and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.] However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after. I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear. If anyone can shed any light on this, your help will be much appreciated.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.

      M 1 Reply Last reply
      0
      • C Christian Graus

        My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.

        M Offline
        M Offline
        Mr Morden
        wrote on last edited by
        #3

        Thanks Christian, It wasnt that. It turned out to be a silly error. Another place in the code was calling BeginWaitCursor() EndWaitCursor(). Turns out EndWaitCursor() simply resets the cursor to the standard arrow cursor, not to the previous cursor as would be logical.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups