- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Customizing TTrackBar

Question:

How can I create a trackbar where the track has a thin line on which the slider moves along, rather than a rather big white space which the slider moves along?

Answer:

The following example demonstrates creating a descendant of 
the TTrackbar component that overrides the CreateParams 
method, and clears the TBS_ENABLESELRANGE flag from the 
params style. This results in a Trackbar component that has a 
small thin track for the slider to move upon. Note that the 
TBS_ENABLESELRANGE constant is declared in the CommCtrl unit.

Example:

uses CommCtrl, ComCtrls;

type TMyTrackBar = class(TTrackBar)
  procedure CreateParams(var Params: TCreateParams); override;
end;

procedure TMyTrackBar.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style and not TBS_ENABLESELRANGE;
end;

var
  MyTrackbar : TMyTrackbar;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyTrackBar := TMyTrackbar.Create(Form1);
  MyTrackbar.Parent := Form1;
  MyTrackbar.Left := 100;
  MyTrackbar.Top := 100;
  MyTrackbar.Width := 150;
  MyTrackbar.Height := 45;
  MyTrackBar.Visible := true;
end;



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile