[DUG] Compnent creation question
Paul A Norman
paul.a.norman at gmail.com
Fri Oct 24 22:42:30 NZDT 2008
I Didn't get through all the posts' texts, but don't we need to count
backwards when freeing list type thingies?
for Counter := 0 to Self.Items.Count - 1 do begin
Something like . ....
for Counter := Self.Items.Count - 1down to 0 do begin
Paul
2008/10/16 Robert martin <rob at chreos.co.nz>
> (Resend didn't seem to come through last time)
>
> Hi
>
> Thanks Kyley.
>
> I actually managed to get that somewhat working but picked up a number
> of other issues. for now I have given up and just overridden the clear
> procedure to free the items. Not great but for my purposes adequate.
>
>
> Thanks to all for suggestions and comments.
> Rob
>
>
> Kyley Harris wrote:
> > Override:
> > function GetItemsClass: TCustomComboBoxStringsClass; virtual;
> > abstract;
> > Create your own subclass of TCustomComboBoxStrings and override the
> > Item add and Item delete routines. You need to place a synched copy of
> > your objects into a seperate list so that when the windows handle to
> > the combobox is released or recreated you don't loose your object
> > pointers. you can also add asserts or tests on the combobox.handle
> > rather than letting it crash all the time. then on the destroy of your
> > TCustomCombobox strings free all the objects in the list.. This would
> > be easiest by using a TObjectList with owns objects = true.
> >
> >
> >
> > On Wed, Oct 15, 2008 at 4:22 PM, Robert martin <rob at chreos.co.nz
> > <mailto:rob at chreos.co.nz>> wrote:
> >
> > Hi
> >
> > Just trying to make a TComboBox that automatically frees its items.
> >
> > I have the following code in the destructor
> >
> > if (fAutomaticallyFreeObjects = True)
> > and ((csDesigning in ComponentState) = False) then begin
> > try
> > for Counter := 0 to Self.Items.Count - 1 do begin
> > O := Items.Objects[Counter];
> > if (O <> nil) then begin
> > O.Free;
> > end;
> > end;
> > except
> > on e: exception do begin
> > ShowMessage(IntToStr(i) + ' ' + 'Attempting to
> > automatically free object memory. The following error occured...' +
> > #13#13 + e.message);
> > end;
> > end;
> > end;
> >
> >
> > I get a 'Control '' has no parent error. This happens when
> attempting
> > to access the .Items property. My custom error handling does not
> > trigger.
> >
> > Any suggestions ?
> >
> > Thanks
> > Rob
> > _______________________________________________
> > NZ Borland Developers Group - Delphi mailing list
> > Post: delphi at delphi.org.nz <mailto:delphi at delphi.org.nz>
> > Admin: http://delphi.org.nz/mailman/listinfo/delphi
> > Unsubscribe: send an email to delphi-request at delphi.org.nz
> > <mailto:delphi-request at delphi.org.nz> with Subject: unsubscribe
> >
> >
> >
> >
> > --
> > Kyley Harris
> > Harris Software
> > +64-21-671-821
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > NZ Borland Developers Group - Delphi mailing list
> > Post: delphi at delphi.org.nz
> > Admin: http://delphi.org.nz/mailman/listinfo/delphi
> > Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
> unsubscribe
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
> unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20081024/dbb1915b/attachment.html
More information about the Delphi
mailing list