Casting is good. You really want to subclass TComponentList. (it doesn't take long)

ie. example

  TEditPanels = class(TComponentList)
    function GetItems(Index: Integer): TEditPanel;
    procedure SetItems(Index: Integer; const Value: TEditPanel);
  public
    function Add(AComponent: TEditPanel): Integer;
    function Remove(AComponent: TEditPanel): Integer;
    procedure Insert(Index: Integer; AComponent: TEditPanel);

    property Items[Index: Integer]: TEditPanel read GetItems write SetItems; default;

  end;

//examples

function TEditPanels.GetItems(Index: Integer): TEditPanel;
begin
  result := inherited Items[Index] as TEditPanel;
end;

procedure TEditPanels.Insert(Index: Integer; AComponent: TEditPanel);
begin
  inherited Insert(Index,AComponent);
end;

function TEditPanels.Remove(AComponent: TEditPanel): Integer;
begin
  result := inherited Remove(AComponent);
end;

procedure TEditPanels.SetItems(Index: Integer; const Value: TEditPanel);
begin
  inherited Items[Index] := Value;
end;

-----Original Message-----
From: David O'Brien [mailto:[EMAIL PROTECTED]
Sent: Monday, 31 March 2003 12:36 p.m.
To: Multiple recipients of list delphi
Subject: RE: Re[2]: [DUG]: Array of components


Try
if TDirMonitor(DirMonList.Items[Tval]).Directory = CurrDir then Exit;
you probably need to cast the object to the correct type.

Dave.


-----Original Message-----
From: Alistair George [mailto:[EMAIL PROTECTED]
Sent: Monday, 31 March 2003 12:27 p.m.
To: Multiple recipients of list delphi
Subject: Re[2]: [DUG]: Array of components


Wow, thanks all for that fine bunch of info. After scanning the internet the
info on this subject is not great, so the groups knowledge here has been of very
high standard!

Any chance of an example of the correct way to use the Tcomponentlist?
What I have done is:

declare:
var     DirMonList:Tcomponentlist;

create copies of existing component:
  DirMonList.Add(DirMonitor1);


access properties of new list component (does not work):
  if DirMonList.Items[Tval](DirMonitor1.Directory) = CurrDir then Exit;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to