Is creating a new component a better strategy for reusing such contributions from the slider?
Not necessarily true all the time. (at least by my standards).
What is the best way to create such a new component?
I know three ways to solve your problem.
Way number 1:
create a master component via the new components, where you dynamically create subcomponents Teditand Ttrackbarin a stream Tgroupbox.
as follows I will do it.
unit Combindedittrack;
interface
uses
System.SysUtils, System.Classes, Vcl.Controls, Vcl.comctrls ,Vcl.StdCtrls;
type
TCombindedittrack = class(Tgroupbox)
private
{ Private declarations }
Fedit:tedit;
Ftrackbar: TTrackBar;
procedure editonchangeproc(Sender: TObject);
procedure trackbaroOnchange(Sender: TObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(owner:tcomponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TCombindedittrack]);
end;
constructor TCombindedittrack.Create(owner:tcomponent);
begin
inherited Create(owner);
SetBounds(0, 0, 250, 50);
Fedit:=tedit.Create(self);
with Fedit do
begin
text := ''; //<-- you control the appearence here
top := 10;
left := 10;
height := 27;
width := 50;
parent:=self;
Onchange:=editonchangeproc; // your Onchange event handler for the Tedit
end;
Ftrackbar:=ttrackbar.Create(self);
with Ftrackbar do
begin
top := 10; //<-- you control the appearence here
left := 60;
height := 30;
width := 50;
parent:=self;
Onchange:=trackbaronchangeproc; // your Onchange event handler for the Ttrackbar
end;
end;
destructor TCombindedittrack.Destroy;
begin
Ftrackbar.Free;
Fedit.Free;
inherited;
end;
procedure TCombindedittrack.trackbaroOnchange(Sender: TObject);
begin
// <-- track bar onchange handling here.
end;
procedure TCombindedittrack.editonchangeproc(Sender: TObject);
begin
// <-- edit onchange handling here.
end;
end.
Way number 2:
Use these frames (I'm on a 10 seattle dolphin).
1) → → → ( delphi).
2) Onchange.
3) .
4) ( ) .
5) .
, .
№ 3:
( delphi 10 )
1) Tedit Ttrackbar.
2) "" " ".
3) OK.
4) Template, .
, () .
, delphi IDE, , , , .
:. , , . , .
,
1. (), ( ).
2. , ( , ).
3. .
4. .
, .
№ 1:
C1 ( № 1): , / . 3.
C2: , 5 , , delphi. , - , , (. C1)
C3: (-) , , (, Tedit ).
C4: , , , Flatstyle Indy. - , , .
№ 2:
C1: 1, , . , .
Onchange
procedure TForm1.Frame2Edit1Change(Sender: TObject);
begin
Frame2.Edit1Change(Sender);
end;
C2: , , , 1.
C3: , , 1.
C4:, 1, , A B. , A.
3:.
1: , repleca/macro , . , .
C2: , , , 1.
C3: , , ( , ).
C4: , A B. , A, B (. c1) , B ( , ).
: , . . 1 , . .
, 1 , , . , , , ( , Tedit , , , ).
, , 1, .