Delphi: Problems with TList of Frames

Posted by Dan Kelly on Stack Overflow See other posts from Stack Overflow or by Dan Kelly
Published on 2011-01-10T16:30:56Z Indexed on 2011/01/10 17:53 UTC
Read the original article Hit count: 269

Filed under:
|
|

I'm having a problem with an interface that consists of a number of frames (normally 25) within a TScrollBox.

There are 2 problems, and I am hoping that one is a consequence of the other...

Background:

When the application starts up, I create 25 frames, each containing approx. 20 controls, which are then populated with the default information. The user can then click on a control to limit the search to a subset of information at which point I free and recreate my frames (as the search may return < 25 records)

The problem:

If I quit the application after the initial search then it takes approx. 5 seconds to return to Delphi. After the 2nd search (and dispose / recreate of frames) it takes approx. 20 seconds)

Whilst I could rewrite the application to only create the frames once, I would like to understand what is going on.

Here is my create routine:

procedure TMF.CreateFrame(i: Integer; var FrameBottom: Integer);
var
   NewFrame: TSF;
begin
   NewFrame := TSF.Create(Self);
   NewFrame.Name := 'SF' + IntToStr(i);
   if i = 0 then
      NewSF.Top := 8
   else
      NewSF.Top := FrameBottom + 8;
   FrameBottom := NewFrame.Top + NewFrame.Height;
   NewFrame.Parent := ScrollBox1;
   FrameList.Add(NewFrame);
end;

And here is my delete routine:

procedure TMF.ClearFrames;
var
   i: Integer;
   SF: TSF;
begin
   for i := 0 to MF.FrameList.Count -1  do
   begin
      SF := FrameList[i];
      SF.Free;
   end;
   FrameList.Clear;
end;

What am I missing?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about frames