# vtkMFCWindow in v8.2.0 for Win32 GUI support has an error handling message WM\_MOUSEWHEEL

**URL:** <https://discourse.vtk.org/t/vtkmfcwindow-in-v8-2-0-for-win32-gui-support-has-an-error-handling-message-wm-mousewheel/1921>\
**Category:** Development\
**Created:** [October 14, 2019, 8:16am UTC](https://discourse.vtk.org/t/vtkmfcwindow-in-v8-2-0-for-win32-gui-support-has-an-error-handling-message-wm-mousewheel/1921 "2019-10-14T08:16:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stilles](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@Stilles](https://discourse.vtk.org/u/Stilles)\
**Post date:** [October 14, 2019, 8:16am UTC](https://discourse.vtk.org/t/vtkmfcwindow-in-v8-2-0-for-win32-gui-support-has-an-error-handling-message-wm-mousewheel/1921/1 "2019-10-14T08:16:26Z")

</div>

Finally, I get here to report this error and hope some one can fix it in later versions.  
Here is piece code handling WM\_MOUSEWHEEL in vtkMFCWindow.cxx:

> BOOL vtkMFCWindow::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)  
> {  
> if(zDelta \> 0)  
> static\_cast\<vtkWin32RenderWindowInteractor\*\>(this-\>GetInteractor())-\>  
> OnMouseWheelForward(this-\>GetSafeHwnd(), nFlags, point.x, point.y);  
> else  
> static\_cast\<vtkWin32RenderWindowInteractor\*\>(this-\>GetInteractor())-\>  
> OnMouseWheelBackward(this-\>GetSafeHwnd(), nFlags, point.x, point.y);  
> return TRUE;  
> }

which assume the parameter passed in “point” is in window **client area** , but it does not,  
according to MSDN `https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel`, the “point” passed as LPARAM for WM\_MOUSEWHEEL is in **screen space**. I trace the calling chain underneath, the “point” will never be translated into client space, which will cause error when I override the handler of OnMouseWheelForwad and OnMouseWheelBackward in derived class of vtkInteractorStyle.

To fix this error, just review the following code segment:

> BOOL vtkMFCWindow::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)  
> {  
> /// Point is in screen space, translate to the client space.  
> /// This is a bug not fixed by VTK developers.  
> ScreenToClient(&point);  
> if(zDelta \> 0)  
> static\_cast\<vtkWin32RenderWindowInteractor\*\>(this-\>GetInteractor())-\>  
> OnMouseWheelForward(this-\>GetSafeHwnd(), nFlags, point.x, point.y);  
> else  
> static\_cast\<vtkWin32RenderWindowInteractor\*\>(this-\>GetInteractor())-\>  
> OnMouseWheelBackward(this-\>GetSafeHwnd(), nFlags, point.x, point.y);  
> return TRUE;  
> }

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [March 16, 2020, 2:30pm UTC](https://discourse.vtk.org/t/vtkmfcwindow-in-v8-2-0-for-win32-gui-support-has-an-error-handling-message-wm-mousewheel/1921/2 "2020-03-16T14:30:58Z")

</div>

I’m not an MFC user, but I’ve submitted your diff here: [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/6578](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/6578)
