| |

VerySource

 Forgot password?
 Register
Search
View: 891|Reply: 2

Ask about the issue of memory release. (The dynamically created controls are saved in Tlist)

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-14 19:00:01
| Show all posts |Read mode
I dynamically add some controls (TButton, TEdit, TLabel...) when the strategy program is running.
And save them in Tlist. Please teach me how to release these controls.

I want to use the RTTI method to obtain the ClassName of the object according to the object pointed to by list[i].
Get the Destroy procedure of the object according to ClassName, and then call the procedure.
Is there a problem with this? Please expert guidance.
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-14 20:00:01
| Show all posts
for i:=0 to List1.Count-1 do
begin
FreeAndNil(List1.Items[i]);
List1.Delete(i);
end;
Reply

Use magic Report

0

Threads

40

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-12-14 21:00:01
| Show all posts
var
  T:Tlist;
  I:Integer;
begin

.....

for I:=T.Count-1 downto 0 do
begin
  TObject(T.Items[i]).Free;
  T.Delete(I);
end;
end;
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list