Events for run time created components
An application I am working on needs to create some components at run-time.
The problem is how to inherit an existing component's event, or create at
run-time new events.
Here is my approach:
...
type
{ an array of RichEdit components }
TRich = array [1..100] of TRichEdit;
...
var
Rich: TRich;
{ a counter used to create new RichEdit components }
{ and 'i' is used to refer array element }
Count, i: Integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ set counter to zero }
Count := 0;
end;
procedure TForm1.cmdNewRichClick(Sender: TObject);
begin
{ increase the count }
Count := Count + 1;
{ create a new RichEdit component in array }
Rich[Count] := TRichEdit.Create(self);
with Rich[Count] do
begin
Parent := Form1;
Text := 'RichEdit';
end;
end;
end.
As far as creating and handling run-time components this seems to work
fine, but Rich[i] has no events, such as OnChange, or OnKeyDown. Is it
possible for these new RichEdit components, in the array, to respond to
events, or inherit events from an existing RichEdit component? If so How?
Anthony M Walter
email: antho...@metrolink.net