Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TDBAdvTrackBar
How to draw a custom tickmark at thumb position

To draw a custom tickmark at thumb position, drop a default TAdvTrackBar on the form and add following code:

procedure TForm2.AdvTrackBar1Change(Sender: TObject); begin
  AdvTrackBar1.Invalidate;
end;

procedure TForm2.AdvTrackBar1DrawTick(Sender: TObject; Canvas: TCanvas;
  Location: TPoint; Position: Integer; TickPos: TTickMark; var Length:
Integer;
  var Color, TextColor: TColor; var Text: string; var DefaultDraw: Boolean); begin
  if Position = AdvTrackBar1.Position then
  begin
    DefaultDraw := false;
    Canvas.MoveTo(Location.X, Location.Y);
    Canvas.Pen.Color := cLRed;
    Canvas.Pen.Width := 3;
    Canvas.LineTo(Location.X, Location.Y + 10);
    Canvas.Pen.Width := 1;
    Canvas.Pen.Color := clBlack;
  end;
end;

This will draw at thumb position a think red tickmark: