Page 1 of 1

Hooking up Scroll with a mouse button (other than default)

Posted: Wed Jun 01, 2005 2:09 pm
by 9526461
Hi

I'm trying to hook up the built-in scroll facility to Left Mouse Button + Shift. (I've disabled the middle button and the straight forward Mouse Down event for left and right buttons are used for something else.)

In a "Mouse Down" event, tried to enable the chart scroll when the left button was down and shift key was down. I also tried it with "Mouse Move" event. Neither worked. (It gets as far as recognising the mouse button type and shift key down.)

Any advice? Please?

And please don't give me a VB code example, cos I can't read it! I'm a very C++ person...

Thanks

Posted: Wed Jun 15, 2005 2:50 pm
by Pep
Hi,
this can be done with the following code (Appologies for VB code, it's not so difficult to translate it to vc++, if you have any problem translating it let me know) :

Code: Select all

Dim go As Boolean
Dim ClickX, ClickY, BAxisMin, BAxisMax, LAxisMin, LAxisMax As Long
 
Private Sub Form_Load()
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues 20
    .Zoom.Enable = False
    .Scroll.Enable = pmNone
End With
End Sub
 
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If Button = mbLeft And Shift = ssShift Then
    ClickX = X
    ClickY = Y
    With TChart1
        BAxisMin = .Axis.Bottom.Minimum
        BAxisMax = .Axis.Bottom.Maximum
        LAxisMin = .Axis.Left.Minimum
        LAxisMax = .Axis.Left.Maximum
    End With
     go = True
End If
End Sub
 
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim XDiff, YDiff, XRange, YRange As Long
If go = True Then
    With TChart1
        XDiff = .Series(0).XScreenToValue(ClickX) - .Series(0).XScreenToValue(X)
        YDiff = .Series(0).YScreenToValue(ClickY) - .Series(0).YScreenToValue(Y)
        .Axis.Bottom.SetMinMax BAxisMin + XDiff, BAxisMax + XDiff
        .Axis.Left.SetMinMax LAxisMin + YDiff, LAxisMax + YDiff
        Label1.Caption = XDiff
    End With
End If
End Sub
 
Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If Button = mbLeft Then
    go = False
End If
End Sub