How to auto-scroll the chart when the user drags an allocation past the edge.


Drop a timer on the form, and attach the following events:

procedure TForm1.RACAllocationDragStart(
    Sender: TObject;
    Resource: TssResource;
    Allocation: TssResourceAllocation;
    var AllowDrag: Boolean);
begin
  Timer1.Interval := 100;
  Timer1.Enabled := true;
end;

procedure TForm1.RACAllocationDragEnd(
    Sender: TObject;
    Resource: TssResource;
    Allocation: TssResourceAllocation);
begin
  Timer1.Enabled := false;
end;

procedure TForm1.RACAllocationDragCancel(
    Sender: TObject;
    Resource: TssResource;
    Allocation: TssResourceAllocation);
begin
  Timer1.Enabled := false;
end;

procedure TForm1.TssRACAllocationSwitchResource(
    Sender: TObject;
    FromResource, ToResource: TssResource;
    Allocation: TssResourceAllocation);
begin
  Timer1.Enabled := false;
end;

// this event handler only fires when an allocation is being dragged
procedure TForm1.Timer1Timer(Sender: TObject);
var
  pt: TPoint;
begin
  with TssRAC do begin
    pt := ScreenToClient(Mouse.CursorPos);

    // scroll horizontally?
    if pt.x < PlotRect.Left then
      ScrollChart(-(EndAt - StartAt) / 25.0)
    else if pt.x > PlotRect.Right then
      ScrollChart((EndAt - StartAt) / 25.0);

    // scroll vertically?
    if pt.y > PlotRect.Bottom then
      FirstDisplayedIndex := FirstDisplayedIndex + 1
    else if pt.y < PlotRect.Top then
      FirstDisplayedIndex := FirstDisplayedIndex - 1;
  end;
end;
What People Say

... The conclusion cannot be an other one than to state that if you are looking for a planning component you have to get the RAC. For your future planning business it is simply a must.
H. de Boer, Staaf Automatisering (see the full case study)
More …

No malware No spam
McAfee Site Report
Web of Trust