Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

cwgraph3d panning with right mouse button

Hi,

I know you can pan a cwgraph3d (when trackmode = cwG3DTrackZoomPanRotate) by holding the shift button.

I want to make panning occur when the user holds the right mouse button and moves the cursor on the image.

I've tried setting the shift =1 in mousedown/mousemove/mouseup but that doesn't work obviously cuz the control must read straight from the keyboard.

Any ideas?

Kevin
0 Kudos
Message 1 of 3
(6,425 Views)
Hello,

The best way to make the 3DGraph pan when you click the right mouse button is to use the Windows user32.dll to programmatically press the shift button. The idea is on the MouseDownEvent you can check to see if the right mouse button was clicked, and then programmatically press the shift key and the left mouse button using the user32.dll. Then when you move the mouse the 3DGraph will pan. Then on the MouseUpEvent you can programmatically release the shift key and the left mouse button. Here is some sample code I wrote in VB.NET which demonstrates this.

Declare Auto Sub keybd_event Lib "user32" (ByVal vK As Integer, ByVal scan As Integer, ByVal flags As Long, ByVal extraInfo As Integer)

Declare Auto Sub mouse_event Lib "user32" (ByVal flags As Integer, ByVal x As Integer, ByVal y As Integer, ByVal data As Integer, ByVal extraInfo As Long)


Private Sub AxCWGraph3D1_MouseDownEvent(ByVal sender As Object, ByVal e As AxCW3DGraphLib._DCWGraph3DEvents_MouseDownEvent) Handles AxCWGraph3D1.MouseDownEvent

If e.button = 2 Then 'Checks to see if the right mouse button was clicked

keybd_event(&HA0, 0, 0, 0) 'Programmatically holds down the shift key
mouse_event(2, e.x, e.y, 0, 0) 'Programmatically holds doen the left mouse button

End If

End Sub

Private Sub AxCWGraph3D1_MouseUpEvent(ByVal sender As Object, ByVal e As AxCW3DGraphLib._DCWGraph3DEvents_MouseUpEvent) Handles AxCWGraph3D1.MouseUpEvent

If e.button = 2 Then 'Checks to see if the right mouse button was released

mouse_event(4, e.x, e.y, 0, 0) 'Programmatically releases the left mouse button
keybd_event(&HA0, 0, 2, 0) 'Programmatically releases the shift key

End If

End Sub


I hope this information is helpful for you.

Regards,
Kevin L.
Applications Engineer
National Instruments
Message 2 of 3
(6,405 Views)
Thank you so much!

That works great!
0 Kudos
Message 3 of 3
(6,399 Views)