How to add an allocation when the user right-clicks on the chart.

Use something like this.

procedure TForm1.RACRightClick(Sender: TObject);
  resource: TssResource;
  slot: TssResourceAllocation;
  pt: TPoint;
  StartAt, EndAt: TDateTime;
  // convert the mouse position to local co-ordinates
  pt := RAC.ScreenToClient(Mouse.CursorPos);
  // find the nearest resource
  resource := RAC.FindResourceFromY(pt.y);
  if Assigned(resource) then begin
    // find the date/time equivalent to where the user clicked
    StartAt := RAC.XToDateTime(pt.x);
    // make the allocation 2 hours long by default,
    // centered on the click
    StartAt := StartAt - EncodeTime(1,0,0,0);
    EndAt := StartAt + EncodeTime(1,0,0,0);
    // if this slot is available then add a new allocation
    if resource.IsSlotFree(StartAt, EndAt) then
      slot := resource.AddSlot(StartAt, EndAt)
What People Say

I did want to drop you a note and tell you what a wonderful component. It's a must have component if you are a serious Delphi developer.
Miguel Henley, Brazil
More …

No malware No spam
McAfee Site Report
Web of Trust