Delphi: How to store TCUSTOMFRAME and record in a list

I am using TObjectList to store TCustomFrames. Now I want to store more information about TCustomFrame in the same list. The record will be good.

Which delphi class do you want to store in the same list of TCustomFrame and records?

TCustomFrames and records will be added at runtime.

create a record to Save all information:

type 
TFrameInfo = record
Frame: TCustomFrame;
Foo: string;
Bar : Integer;
end;

Keep it in TList.

I noticed that you are using TObjectList instead of TList. The only benefit of this is if you set OwnsObjects to True. But this seems unlikely because I doubt that the list is really responsible for the life cycle of GUI objects. As a future note, if you find yourself using TObjectList if Set OwnsObjects to False, then you can also switch to TList< T>.

Now, if you really need a list to control the life cycle, then you’d better use the class instead of the record of TFrameInfo.

p>

type 
TFrameInfo = class
private
FFrame: TCustomFrame;
FFoo: string;
FBar: Integer;< br /> public
constructor Create(AFrame: TCustomFrame; AFoo: string; ABar: Integer);
destructor Destroy; override;
property Frame: TCustomFrame read FFrame;
// etc.
end;

constructor TFrameInfo.Create(AFrame: TCustomFrame; AFoo: string; ABar: Integer);
begin< br /> inherited Create;
FFrame := AFrame;
// etc.
end;

destructor TFrameInfo.Destroy;
begin
FFrame.Free;
inherited;
end;

Then save it in TObjectList. Set OwnsObjects to True.

< /p>

I am using TObjectList to store TCustomFrames. Now I want to store more information about TCustomFrame in the same list. The record will be good.

Which one do you want The Delphi class stores TCustomFrame and records in the same list?

TCustomFrames and records will be added at runtime.

Create a record to save all information:

< p>

type 
TFrameInfo = record
Frame: TCustomFrame;
Foo: string;
Bar: Integer;
end;

Keep it in TList.

I noticed that you are using TObjectList instead of TList. The only advantage of this is that if you set OwnsObjects True. But this seems unlikely, because I doubt that the list is really responsible for the life cycle of GUI objects. As a future note, if you find yourself using TObjectList if you set OwnsObjects to False, then you can also switch to TList< T>.

Now, if you really need a list to control the life cycle, then you’d better use the class instead of the TFrameInfo record.

 type 
TFrameInfo = class
private
FFrame: TCustomFrame;
FFoo: string;
FBar: Integer;
public
constructor Create(AFrame : TCustomFrame; AFoo: string; ABar: Integer);
destructor Destroy; override;
property Frame: TCustomFrame read FFrame;
// etc.
end;

constructor TFrameInfo.Create(AFrame: TCustomFrame; AFoo: string; ABar: Integer);
begin
inherited Create;
FFrame := AFrame;
// etc.
end;

destructor TFrameInfo.Destroy;
begin
FFrame.Free;
inherited;
end;

Then save it in TObjectList. Set OwnsObjects to True.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3171 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.