Duncan Parsons wrote:
Not got Laz/fpc code near me, but my guess is that when you have a
TTrackBar on the form, the unit that it's housed in will be added to the
uses list, and if you delete it (provided no other referenced classes
are included) it may get removed.

Find which unit TTrackBar is declared in and add it to the relevant uses
clause by hand..

Does that help?

No, not really. I had already thought along the same lines and checked it out.

I would have thought that given I'm referencing TTrackBar in the array definition it would grumble if the unit was not in the uses clause anyway.

Thanks for the thought tho. I've certainly been caught by errors like this in 
the past.

For reference, here is the complete procedure.
The form var section has this :

Var
  TapSliders : Array[0..15] of TTrackBar;
  TapLabels : Array[0..15] of TLabel;

This is where I create some of the sliders.

Any suggestions on how I can de-crapify this process is most welcome too :) I'm creating an array of sliders at run time which are all aligned against each other on a panel in 2 rows. I've fixed the numbers for testing purposes, but it has / will been / be dynamic depending on the hardware it is talking to.


procedure TForm1.FormCreate(Sender: TObject);
Var
        I : Integer;
begin
  Ser := TBlockSerial.Create;
  For I := 0 to 15 do
      Begin
      TapLabels[I] := TLabel.Create(Panel2);
      TapLabels[I].Layout := tlCenter;
      TapLabels[I].Alignment := taCenter;
      TapLabels[I].Parent := Panel2;
      TapLabels[I].Caption := 'L'+IntToStr(I);
      TapLabels[I].Anchors := [];
      End;

  For I := 0 to 15 do
      Begin
      TapSliders[I] := TTrackBar.Create(Panel2);
      TapSliders[I].Top := 1;
      TapSliders[I].Max := 32768;
      TapSliders[I].Position:= I*50;
      TapSliders[I].Name := 'TapSliders'+IntToStr(I);
      TapSliders[I].Parent := Panel2;
      TapSliders[I].Orientation := trVertical;
      TapSliders[I].TickStyle := tsNone;
      TapSliders[I].OnChange:= @TrackBar1Change;
      TapSliders[I].Tag := I+$ABCD;
      TapSliders[I].BorderSpacing.Left := 10;
      TapSliders[I].Width := TapSliders[I].Width + 5;
      End;

      For I := 0 to 7 do
          Begin
          TapSliders[I].AnchorSide[akTop].Control := Panel2;
          TapSliders[I].AnchorSide[akTop].Side := asrTop;
          TapSliders[I].Height := (Panel2.Height Div 2) - 5 - 
TapLabels[0].Height;
          TapLabels[I].AnchorSide[akTop].Control := TapSliders[I];
          TapLabels[I].AnchorSide[akTop].Side := asrBottom;
          TapLabels[I].AnchorSide[akLeft].Control := TapSliders[I];
          TapLabels[I].AnchorSide[akLeft].Side := asrLeft;
          TapLabels[I].AnchorSide[akRight].Control := TapSliders[I];
          TapLabels[I].AnchorSide[akRight].Side := asrRight;
          TapLabels[I].Anchors := TapLabels[I].Anchors+[akTop,akLeft,akRight];
          End;

      For I := 8 to 15 do
          Begin
          TapSliders[I].AnchorSide[akTop].Control := TapLabels[I-8];
          TapSliders[I].AnchorSide[akTop].Side := asrBottom;
          TapSliders[I].AnchorSide[akBottom].Control := TapLabels[I];
          TapSliders[I].AnchorSide[akBottom].Side := asrtop;
          TapSliders[I].Anchors := TapSliders[I].Anchors+[akBottom];

          TapLabels[I].AnchorSide[akBottom].Control := Panel2;
          TapLabels[I].AnchorSide[akBottom].Side := asrBottom;
          TapLabels[I].AnchorSide[akLeft].Control := TapSliders[I];
          TapLabels[I].AnchorSide[akLeft].Side := asrLeft;
          TapLabels[I].AnchorSide[akRight].Control := TapSliders[I];
          TapLabels[I].AnchorSide[akRight].Side := asrRight;
          TapLabels[I].Anchors := 
TapLabels[I].Anchors+[akBottom,akLeft,akRight];
          End;

      TapSliders[0].AnchorSide[akLeft].Control := Panel2;
      TapSliders[0].AnchorSide[akLeft].Side := asrLeft;

      TapSliders[8].AnchorSide[akLeft].Control := Panel2;
      TapSliders[8].AnchorSide[akLeft].Side := asrLeft;

      For I := 1 to 7 do
          Begin
          TapSliders[I].AnchorSide[akLeft].Control := TapSliders[I-1];
          TapSliders[I+8].AnchorSide[akLeft].Control := TapSliders[I-1+8];
          TapSliders[I].AnchorSide[akLeft].Side := asrRight;
          TapSliders[I+8].AnchorSide[akLeft].Side := asrRight;
          End;
      For I := 0 to 15 do
          TapSliders[I].Anchors := TapSliders[I].Anchors+[akTop,akLeft];
end;

Regards,
Brad
--
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
fish.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to