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