unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, CommCtrl;
// TTrackbar um ein OnChanged Ereignis erweitern
type
TTrackBar =
class(ComCtrls.TTrackBar)
private
FOnChanged : TNotifyEvent;
procedure CNHScroll(
var msg: TWMHScroll);
message CN_HSCROLL;
published
property OnChanged: TNotifyEvent
read FOnChanged
write FOnChanged;
end;
type
TForm1 =
class(TForm)
TrackBar1: TTrackBar;
procedure FormCreate(Sender: TObject);
private
procedure TrackBarChanged(Sender: TObject);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TTrackBar.CNHScroll(
var msg: TWMHScroll);
begin
inherited;
if Assigned(fOnChanged)
then
if (msg.ScrollCode
in [TB_THUMBPOSITION, TB_LINEUP, TB_LINEDOWN, TB_PAGEUP, TB_PAGEDOWN])
then
begin
FOnChanged(Self);
end;
end;
procedure TForm1.TrackBarChanged(Sender: TObject);
begin
Self.Caption := '
Position geändert ! ';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// OnChanged Handler zuweisen
TrackBar1.OnChanged := TrackBarChanged;
end;
end.