Board index » delphi » Help with TScrollBox and memory constraints

Help with TScrollBox and memory constraints

Hi all,

I have a question regarding TScrollBox. I have added a TScrollBox to a
TTabSheet at design time. At runtime, I use a TQuery to fetch records from a
table to determine the number of rows needed in the TScrollBox. Then, I add
4-6 TCheckBoxes and 1-3 TEdits per row to the TScrollBox. Sometimes this can
mean the addition of up to 200 of these rows, equating to 1200 TCheckBoxes
and 300 TEdits. Then another query is performed to determine which of these
rows need to have values set.

I use an object to represent each row (i.e., the TCheckBoxes and TEdits) and
add each object to a TList. I perform the primary TQuery and create the
objects (and add them to a TList) once. When I move to the next record, the
secondary query sets the approriate rows/fields. What is strange is that (I
am using the resource meter) when the TTabSheet with the TScrollBox on it is
selected, the items are drawn and system resources plummet. The items have
already been allocated and placed in the TScrollBox, so I am confused as to
the sudden performance hit upon selecting the TTabSheet containing the
TScrollBox.

The following is the object definition :

TService = class(TObject)
      private
          sLabel : TLabel;
          sConAuth, sAuthReq, sCOD : TCheckBox;
          sAuthLim, sNumAuth, sComments : TEdit;
          sIdNo : integer;
          Constructor Create(Scroll:TScrollBox; IdNo:Integer;
sCaption:String; Item:Integer);
          Destructor Destroy; override;
          procedure Show;
end;

The constructor creates the TLabel,TCheckBoxes and TEdits. Some properties
such as Top and Left are set and the items are initially not visible and not
enabled.
The Parent method is set to Scroll. The Create method is called within a
while loop bounded by a TQuery.EOF condition. After the create, the TService
instance is made visible and add to a TList. When a user queries a record,
the Boxes and Edits are filled based on another query. The TService
instances are Free(d) on FormDestroy (along with the TList) as follows :

procedure TfrmARCustomer.FormDestroy(Sender: TObject);
var
    i : integer;
begin
    if ServicesList <> nil then
    begin
        for i := 0 to ServicesList.Count - 1 do
            TService(ServicesList[i]).Free;
        if ServicesList.Count > 0 then
            ServicesList.Clear;
    end;
    ScrollServices.DestroyComponents;
    ServicesList.Free;
end;

ServicesList is of type TList and is Create(d) on FormCreate.

Any help/insight or willing to review the unit in its entirety is VERY
welcome ( and probably necessary!). I don't know if I'm just creating way
too many controls or if I'm mismanaging the TService objects or the TList.

Thanks in advance,

John Owen
Tom McLeod Software

 

Re:Help with TScrollBox and memory constraints


Quote
John Owen wrote in message <6qs5ta$4i...@forums.borland.com>...
>... Then, I add
>4-6 TCheckBoxes and 1-3 TEdits per row to the TScrollBox. Sometimes this
can
>mean the addition of up to 200 of these rows, equating to 1200 TCheckBoxes
>and 300 TEdits.

Have you considered using the TDBCtrlGrid control? You're using a huge
number of controls, which puts great strain on the system. TDBCtrlGrid will
also manage the data connection for you.

Quote
>... What is strange is that (I
>am using the resource meter) when the TTabSheet with the TScrollBox on it
is
>selected, the items are drawn and system resources plummet.

The resources are allocated when the window handles are created. In some
cases, the handles are created only when  the control (or its parent) is
being displayed.

--
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via e-mail)

Re:Help with TScrollBox and memory constraints


Yorai,
  Will the TDBCtrlGrid allow me to place CheckBoxes and Edits on one row?
Also, I noticed that it does not allow individual panel sizes. We use custom
developed DBControls, etc. here, but I think I can use the DBCtrlGrid. I did
not see an example in the Help. Do you have one you could recommend?

Thanks,

johno

Re:Help with TScrollBox and memory constraints


Quote
John Owen wrote in message <6qsfif$5...@forums.borland.com>...
>  Will the TDBCtrlGrid allow me to place CheckBoxes and Edits on one row?

Yes.

Quote
>I did not see an example in the Help.

See the Demos\Db\CtrlGrid directory.

--
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via e-mail)

Re:Help with TScrollBox and memory constraints


Quote
John Owen wrote in message <6qsfif$5...@forums.borland.com>...
>  Will the TDBCtrlGrid allow me to place CheckBoxes and Edits on one row?

Yes.

Quote
>I did not see an example in the Help.

See the Demos\Db\CtrlGrid directory.

--
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via e-mail)

Re:Help with TScrollBox and memory constraints


Yorai,
  The only thing I really don't like is that each row is posted when you
move to the next row. The implementation I am using allows the user to
change any/all of the rows and then do an update enmasse. Is there a similar
component to this without DB Controls?

Thanks,

John Owen
Tom McLeod Software

Quote
Yorai Aminov (TeamB) wrote in message <6qsq62$5a...@forums.borland.com>...
>John Owen wrote in message <6qsfif$5...@forums.borland.com>...
>>  Will the TDBCtrlGrid allow me to place CheckBoxes and Edits on one row?

>Yes.

>>I did not see an example in the Help.

>See the Demos\Db\CtrlGrid directory.

>--
>Yorai Aminov (TeamB)
>http://ourworld.compuserve.com/homepages/yaminov
>(TeamB cannot answer questions received via e-mail)

Re:Help with TScrollBox and memory constraints


On Thu, 13 Aug 1998 07:10:40 -0500, "John Owen" <jo...@tmscorp.com>
wrote:

Quote
>  The only thing I really don't like is that each row is posted when you
>move to the next row. The implementation I am using allows the user to
>change any/all of the rows and then do an update enmasse. Is there a similar
>component to this without DB Controls?

No. There might be a third-party tool that does that, but not one that
I'm aware of.

---
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via email.
To contact me for any other reason remove nospam from my address)

Other Threads