The TTMSFNCTrackBar is a great component to use with lots of settings. Only the corners are not rounded.
Is there an easy way to have rounded corners for the component or for the component to follow the parent that has rounded corners?
Do we need to redraw everything in the OnBeforeDraw event?
When it is done in the OnBeforeDraw event the Thumb, TrackLine... also has to be redrawn.
Perhaps there is a possibility in the OnBeforeDrawTrackLine event?
We are not using the buttons in this specific case, we only want the background to change depending on the position of the thumb (max 3 positions).
Hi,
The OnBeforeDraw
event should be sufficient as long as you prevent the original background from drawing:
procedure TForm3.FormCreate(Sender: TObject);
begin
TMSFNCTrackBar1.DisableBackground;
TMSFNCTrackBar1.Max := 2;
TMSFNCTrackBar1.Appearance.TickMarkPosition := tmpNone;
end;
procedure TForm3.TMSFNCTrackBar1BeforeDraw(Sender: TObject;
AGraphics: TTMSFNCGraphics; ARect: TRectF; var ADefaultDraw: Boolean);
begin
if TMSFNCTrackBar1.Value = 0 then
AGraphics.Fill.Color := gcRed
else if TMSFNCTrackBar1.Value = 2 then
AGraphics.Fill.Color := gcGreen
else
AGraphics.Fill.Color := gcOrange;
AGraphics.DrawRoundRectangle(ARect);
end;