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. OnMouseWheel and OnSetCursor interaction

OnMouseWheel and OnSetCursor interaction

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • U Offline
    U Offline
    User 13219589
    wrote on last edited by
    #1

    Hi all, I have the following code which works for zooming in and out BOOL CChildView::OnMouseWheel(UINT nFlags, short zDelta, CPoint point) { if (theApp.pBitmap) { //Caution! point is in screen coordinate! CPoint pClient = point; ScreenToClient(&pClient); if (crDest.PtInRect(pClient)) { m_bMouseWheel = TRUE; if (zDelta == 120) { OnZoomPlus(pClient); } else if (zDelta == -120) { OnZoomMinus(pClient); } m_bMouseWheel = FALSE; } else PlaySound(MAKEINTRESOURCE(IDR_WAV_SPRING), GetModuleHandle(NULL), SND_RESOURCE); } return TRUE; } Normally in SetCursor, the BOOL m_bMouseWheel would change the cursor BOOL CChildView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (m_bMouseDown || m_bMouseWheel)//Todo::Doesnot work for m_bMouseWheel { ::SetCursor(LoadCursor(NULL, IDC_SIZEALL)); return TRUE; } if (theApp.m_hLenseCursor && theApp.bTrackLenseMode) { ::SetCursor(theApp.m_hLenseCursor); return TRUE; } else { ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); } return CWnd::OnSetCursor(pWnd, nHitTest, message); } but actually nothing happens. Any suggestion? Pierre

    L 1 Reply Last reply
    0
    • U User 13219589

      Hi all, I have the following code which works for zooming in and out BOOL CChildView::OnMouseWheel(UINT nFlags, short zDelta, CPoint point) { if (theApp.pBitmap) { //Caution! point is in screen coordinate! CPoint pClient = point; ScreenToClient(&pClient); if (crDest.PtInRect(pClient)) { m_bMouseWheel = TRUE; if (zDelta == 120) { OnZoomPlus(pClient); } else if (zDelta == -120) { OnZoomMinus(pClient); } m_bMouseWheel = FALSE; } else PlaySound(MAKEINTRESOURCE(IDR_WAV_SPRING), GetModuleHandle(NULL), SND_RESOURCE); } return TRUE; } Normally in SetCursor, the BOOL m_bMouseWheel would change the cursor BOOL CChildView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (m_bMouseDown || m_bMouseWheel)//Todo::Doesnot work for m_bMouseWheel { ::SetCursor(LoadCursor(NULL, IDC_SIZEALL)); return TRUE; } if (theApp.m_hLenseCursor && theApp.bTrackLenseMode) { ::SetCursor(theApp.m_hLenseCursor); return TRUE; } else { ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); } return CWnd::OnSetCursor(pWnd, nHitTest, message); } but actually nothing happens. Any suggestion? Pierre

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 13251588 wrote:

      Any suggestion?

      Use the debugger to step through the code and see what is actually happening, especially when the code enters one of the zoom functions.

      U 1 Reply Last reply
      0
      • L Lost User

        Member 13251588 wrote:

        Any suggestion?

        Use the debugger to step through the code and see what is actually happening, especially when the code enters one of the zoom functions.

        U Offline
        U Offline
        User 13219589
        wrote on last edited by
        #3

        Under debugger m_bMouseWheel (which is global to the class) is always true. The problem is maybe that OnSetCursor is not triggered during that time (one mousewheel). The doc say that "The WM_SETCURSOR message is sent to a window if the mouse causes the cursor to move within a window" which is not the case when mousewheeling. So I am thinking on SendMessage(WM_SETCURSOR, some "params") before entering Zoom function. But actually I do not know what to use as "params". Is it a good track? Pierre

        L 1 Reply Last reply
        0
        • U User 13219589

          Under debugger m_bMouseWheel (which is global to the class) is always true. The problem is maybe that OnSetCursor is not triggered during that time (one mousewheel). The doc say that "The WM_SETCURSOR message is sent to a window if the mouse causes the cursor to move within a window" which is not the case when mousewheeling. So I am thinking on SendMessage(WM_SETCURSOR, some "params") before entering Zoom function. But actually I do not know what to use as "params". Is it a good track? Pierre

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry, I am not sure what that has to do with your original question. If you want to zoom an image based on the mouse wheel then you just need to capture the mouse movement and call your zoom function with suitable parameter values.

          U 1 Reply Last reply
          0
          • L Lost User

            Sorry, I am not sure what that has to do with your original question. If you want to zoom an image based on the mouse wheel then you just need to capture the mouse movement and call your zoom function with suitable parameter values.

            U Offline
            U Offline
            User 13219589
            wrote on last edited by
            #5

            Actually SendMessage(WM_SETCURSOR, 0, 0 or use default) before zooming does the trick.

            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