[vtkusers] MouseWheel and .NET
Mathieu Malaterre
mathieu.malaterre at kitware.com
Thu Mar 9 12:51:38 EST 2006
Thanks for taking the time to report solution to the ML.
Mathieu
David Montgomery wrote:
> I verified that the focused .NET component consumes the WM_MOUSEWHEEL
> message, and the VTK graphics window would not receive it. I worked
> around this by simply overriding the following .NET method:
>
> OnMouseWheel(MouseEventArgs e)
>
> Using the value of e.Delta I directed this method to call the
> appropriate MouseWheel method of the VTK interactor as follows:
>
> if (forward) {
>
> this->trackballCam->OnMouseWheelForward();
>
> } else {
>
> this->trackballCam->OnMouseWheelBackward();
>
> }
>
>
> ------------------------------------------------------------------------
> *From:* Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com]
> *Sent:* Wed 3/8/2006 5:11 PM
> *To:* David Montgomery
> *Cc:* vtkusers at vtk.org
> *Subject:* Re: [vtkusers] MouseWheel and .NET
>
> David Montgomery wrote:
> > In VTK 5.0.0 mouse wheel input zooms the trackball interactor as
> > expected when I use a stand alone win32 window. When I parent the VTK
> > graphics window to a .NET Windows Forms component (such as a panel), the
> > mouse wheel input apparently gets consumed by a .NET component. Does
> > anyone know a work-around or setting I should use to get the mouse wheel
> > input to the VTK window?
>
> Be sure to propagate the events down to VTK. Have a look at:
>
> VTK/Examples/GUI/Win32/SampleMFC/vtkMFCRenderView.cpp
>
> ...
> // Define our own event handler here
> LRESULT vtkMFCRenderView::WindowProc(UINT message, WPARAM wParam, LPARAM
> lParam)
> {
> switch (message)
> {
> //case WM_PAINT:
> case WM_LBUTTONDOWN:
> case WM_LBUTTONUP:
> case WM_MBUTTONDOWN:
> case WM_MBUTTONUP:
> case WM_RBUTTONDOWN:
> case WM_RBUTTONUP:
> case WM_MOUSEMOVE:
> case WM_MOUSEWHEEL:
> case WM_CHAR:
> case WM_TIMER:
> if (this->Interactor->GetInitialized())
> {
> return vtkHandleMessage2(this->m_hWnd, message, wParam, lParam,
> this->Interactor);
> }
> break;
> }
> return vtkMFCView::WindowProc(message, wParam, lParam);
> }
> ...
>
> HTH
> Mathieu
>
More information about the vtkusers
mailing list