OnMouseWheel and OnSetCursor interaction
-
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
-
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
-
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.
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
-
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
-
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.
Actually SendMessage(WM_SETCURSOR, 0, 0 or use default) before zooming does the trick.