Changing MouseWheelMode if control key pressed
Changing MouseWheelMode if control key pressed
In GDViewer, how can I force the MouseWheelMode to be MouseWheelModeVerticalScroll if I use the mouse wheel alone, but MouseWheelModeZoom if I use the mouse wheel with the control key pressed?
I tried using the ViewerMouseWheel event, but it does not indicate whether the control key is pressed or not.
I tried using the ViewerMouseWheel event, but it does not indicate whether the control key is pressed or not.
Re: Changing MouseWheelMode if control key pressed
Hello,
I do not really understand what you are trying to do. Could you clarify ?
Thank you for any hint.
Kind regards,
Loïc
I do not really understand what you are trying to do. Could you clarify ?
Thank you for any hint.
Kind regards,
Loïc
Re: Changing MouseWheelMode if control key pressed
I want the GDViewer to scroll when I use the mouse wheel, but when I press CTRL + mouse wheel, I want it to zoom. I want it to have the same behavior as most Microsoft products, which allow you to scroll with the mouse wheel alone, and zoom with CTRL + mouse wheel.
I have been able to use the ViewerKeyUp and ViewerKeyDown events to change the mode from MouseWheelModeVerticalScroll to MouseWheelModeZoom when the user presses the Control key, but I am finding that these events don't fire every time. They only seem to work when I fit the image to the viewer using SetZoomFitViewer.
Let me know if you need any more information.
I have been able to use the ViewerKeyUp and ViewerKeyDown events to change the mode from MouseWheelModeVerticalScroll to MouseWheelModeZoom when the user presses the Control key, but I am finding that these events don't fire every time. They only seem to work when I fit the image to the viewer using SetZoomFitViewer.
Let me know if you need any more information.
Re: Changing MouseWheelMode if control key pressed
Hello,
OK it's not so hard to do.
Please turn false the EnableMouseWheel property. And the catch KeyDown, KeyUp & MouseWheel events as following:
Hope this helps!
Kind regards,
Loïc
OK it's not so hard to do.
Please turn false the EnableMouseWheel property. And the catch KeyDown, KeyUp & MouseWheel events as following:
Code: Select all
Private m_CtrlKeyDown As Boolean
Private Sub GdViewer1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GdViewer1.MouseWheel
If m_CtrlKeyDown Then
If e.Delta > 0 Then
GdViewer1.ZoomIN()
Else
GdViewer1.ZoomOUT()
End If
Else
If e.Delta < 0 Then
GdViewer1.SetVScrollBarPosition(GdViewer1.GetVScrollBarPosition + GdViewer1.ScrollLargeChange)
Else
GdViewer1.SetVScrollBarPosition(GdViewer1.GetVScrollBarPosition - GdViewer1.ScrollLargeChange)
End If
End If
End Sub
Private Sub GdViewer1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GdViewer1.KeyDown
m_CtrlKeyDown = e.Control
End Sub
Private Sub GdViewer1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GdViewer1.KeyUp
m_CtrlKeyDown = False
End Sub
Kind regards,
Loïc
Who is online
Users browsing this forum: No registered users and 1 guest