Page 1 of 1

OnGanttToolDragBar

Posted: Wed May 05, 2010 1:17 pm
by 9527827
Hi
Im trying to use the gannt drag and resize but also want to keep right click menus I have added. This is a Visual Foxpro application.
The problem I am having is a right click will give me the menu I require, but also continue moving the bar which I dont want. I only want drag and resize if the left click is down not the right click. I have tried setting the pointer.asgantt.allowdrag and allowresize in the seriesclick depending on the button but this does not seem to work.
Any advice please.
Regards
Allen

Re: OnGanttToolDragBar

Posted: Wed May 05, 2010 4:05 pm
by 9527827
I should have added this is using version 7 of the activex

Re: OnGanttToolDragBar

Posted: Thu May 06, 2010 8:51 am
by narcis
Hi Allen,

I've found this only occurs when you have disabled scrolling in your chart. You could either enable it or set a different mouse button for it. You'll find more information on how ot do that in tutorial 11. Tutorials can be found at TeeChart's program group.

Re: OnGanttToolDragBar

Posted: Sun May 09, 2010 12:54 pm
by 9527827
Thanks for the reply. I had disabled scroll and zoom because I do not want it used. I have decided to have modes for the chart so the user can decide on the mode to use like the right click menu or move or zoom.
One other question, I can use the tools for moving in time, what is the best way to have drag drop in vertical, ie from one line to another rather than across the chart.
Thanks
Allen

Re: OnGanttToolDragBar

Posted: Mon May 10, 2010 11:39 am
by narcis
Hi Allen,

In that case you should try DragPoints tool.

Hope this helps!

Re: OnGanttToolDragBar

Posted: Tue Jul 06, 2010 10:02 am
by 9527827
Sorry for the delay, been very busy. I am now trying the drag point but it seems unclear what to do with it as it does not snap to the axis. At the moment I am just wanting drag style "Y" but it can leave the point (gantt) anywhere. I can see OnDragPointToolDragPoint but am unsure what to do with it. I need to use the new position to change the data. Any advice please or pointer to a demo
Thanks
Allen

Re: OnGanttToolDragBar

Posted: Wed Jul 07, 2010 2:21 pm
by yeray
Hi Allen,

I'm not sure to understand how you would like the points to snap to the axis. Here you have an example of how you could customize the Gantt series drag using the Mouse events. Note that this is a VB6 example.

Code: Select all

Dim MouseStartX, MouseStartY, clickedIndex As Integer

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  
  TChart1.AddSeries scGantt
  TChart1.Series(0).FillSampleValues 10
  
  TChart1.Zoom.Enable = False
  TChart1.Scroll.Enable = pmNone
  
  clickedIndex = -1
  MouseStartX = -1
  MouseStartY = -1
End Sub


Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  clickedIndex = TChart1.Series(0).Clicked(X, Y)
  If clickedIndex <> -1 Then
    MouseStartX = X
    MouseStartY = Y
    TChart1.Header.Text.Text = Str$(clickedIndex)
  End If
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If clickedIndex <> -1 Then
    With TChart1.Series(0).asGantt
      .StartValues.Value(clickedIndex) = .StartValues.Value(clickedIndex) + TChart1.Axis.Bottom.CalcPosPoint(X) - TChart1.Axis.Bottom.CalcPosPoint(MouseStartX)
      .EndValues.Value(clickedIndex) = .EndValues.Value(clickedIndex) + TChart1.Axis.Bottom.CalcPosPoint(X) - TChart1.Axis.Bottom.CalcPosPoint(MouseStartX)
    End With
    
    TChart1.Series(0).YValues.Value(clickedIndex) = TChart1.Series(0).YValues.Value(clickedIndex) + TChart1.Axis.Left.CalcPosPoint(Y) - TChart1.Axis.Left.CalcPosPoint(MouseStartY)
    
    MouseStartX = X
    MouseStartY = Y
  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)
  clickedIndex = -1
End Sub