program Project1;
uses kol,KOLCCtrls,messages;
var
form:PControl;
TrackBar8:PTrackbar;
CtrlList:PList;
procedure MouseDown(dummy:pointer;Sender:PControl; var mouse:TMouseEventData);
begin
if (Mouse.Button = mbLeft) then Begin
PControl(sender).SetAlign ( caClient ).CenterOnParent.Tabulate;
PControl(sender).BringToFront;
PControl(sender).Caption:='Click In ';
End
else
begin
PControl(sender).SetAlign ( caNone );
PControl(sender).SetSize(95,56).SetPosition(10+(PControl(sender).Tag-1) * 98,20).SetBorder( 2);
PControl(sender).Caption:='Click Out '
end;
Mouse.StopHandling := TRUE;
end;
procedure MouseUP(dummy:pointer;Sender:PControl; var mouse:TMouseEventData);
begin
end;
procedure TrackBar8Change(Dummy: Pointer;Sender: PTrackbar; Code: Integer);
var i:Integer;
begin
form.Caption:='TrackBarPosition '+int2str(TrackBar8.Position);
if TrackBar8.Position = CtrlList.Count then Exit;
if TrackBar8.Position < CtrlList.Count then
begin
for i := CtrlList.Count - 1 downto TrackBar8.Position do begin
PObj(CtrlList.Items[i]).Free;
CtrlList.Delete(i);
end;
end else
for i := CtrlList.Count to TrackBar8.Position-1 do begin
CtrlList.Add(NewPanel(form,esRaised).SetSize(95,56).SetPosition(10+(TrackBar8.Position - 1) * 98,20).SetBorder( 2));
PControl(CtrlList.Items[i]).OnMouseDown:=TOnMouse(MakeMethod(nil,@MouseDown));
PControl(CtrlList.Items[i]).Tag:=TrackBar8.Position;
end;
form.Update;
form.Invalidate
end;
procedure FormCreate(Sender: PObj);
begin
CtrlList:= NewList;
end;
Begin
form:=NewForm(Applet,'Баттон трак бар').CenterOnParent.Tabulate;
TrackBar8 := PTrackbar( NewTrackBar( form, [trbAutoTicks,trbEnableSelRange],
TOnScroll(MakeMethod(nil,@TrackBar8Change))).SetSize( 537, 45 ));
TrackBar8.RangeMax :=7;
TrackBar8.RangeMin:=0;
TrackBar8.TickFreq:=1;
TrackBar8.SetAlign ( caBottom );
TrackBar8.Perform( WM_SETFOCUS, 0, 0);
Applet := NewApplet('');
FormCreate(nil);
form.Text:='';
Run(form);
end.