How to click and drag to create a new allocation.

Try this, it looks really good. (Thanks to Marc Hoffmann for this snippet.)

  TUnleashedChart = class(TssResourceAllocationChart);

procedure TForm1.RACMouseDown(Sender: TObject;
                              Button: TMouseButton;
                              Shift: TShiftState;
                              X, Y: Integer);
  Resource: TssResource;
  NewAlloc: TssResourceAllocation;
  StartAt, EndAt, MinimumSpan: TDateTime;
  Pt: TPoint;
  // don't create allocations if dragging the chart
  if not (racAllowDragScroll in RAC.Options) then begin
    Resource := RAC.FindResourceFromY(Y);
    if Assigned(Resource) then begin
      StartAt := RAC.XToDateTime(X);

      // need at least three pixels to allow the
      // sizing handle to be grabbed
      EndAt := RAC.XToDateTime(X + 3);
      MinimumSpan := EncodeTime(0, 15, 0, 0);
      if EndAt < StartAt + MinimumSpan then
        EndAt := StartAt + MinimumSpan;

      if Resource.IsSlotFree(StartAt, EndAt) then begin
        NewAlloc := Resource.AddSlot(StartAt, EndAt);
        NewAlloc.Style := rsBlock;
        Pt := RAC.ClientToScreen(NewAlloc.DisplayRect.BottomRight);
        Pt.X := Pt.X - 1;
        Pt.Y := Pt.Y - (NewAlloc.DisplayRect.Bottom -
                        NewAlloc.DisplayRect.Top) div 2;
        SetCursorPos(Pt.X, Pt.Y);
        Pt := RAC.ScreenToClient(Pt);

        // hook into the normal MouseDown handler
        TUnleashedChart(RAC).MouseDown(Button, Shift, Pt.X, Pt.Y);
What People Say

This is a great component. I've been using it for a year. It's well written, performance is top notch, and the couple of time I've asked for support, I've gotten it right away from the author.
Steve McForest
More …

No malware No spam
McAfee Site Report
Web of Trust