On 10 Aug 2001, at 0:35, Willie wrote:

dont realy Know But I usually protect my free's with 
if contol[i] <> nil then control[i].free just to stop possible av

> I'm banging my head against something hard (very hard) here.
> 
> Can anyone see what is wrong with the following code....
> 
> First I populate a panel with a number of 1st Class Shape buttons as per....
> 
>   CurrentButton := tfcShapebtn.Create(Nil);
>   with dm.cdsButtons  do
>   begin
>     currentbutton.OnClick := Button1Click;
>     currentbutton.Parent := MainPanel; //
>     currentbutton.Tag := FieldByname('QSButtonID').AsInteger;
>     currentbutton.Name := 'fcShapebtn' +
> IntToStr(FieldByname('QSButtonID').AsInteger);
>  etc etc
> 
> later on I want to free them all (to populate the panel with another
> different set) .....
> 
>   i := MainPanel.ControlCount - 1;
>   while i >= 0 do
>   begin
>     if (MainPanel.Controls[i] is TfcShapebtn) or
>       (MainPanel.Controls[i] is TfcLabel) then
>  MainPanel.Controls[i].Free;
>     i := i - 1;
>   end;
> 
> this AVs on the free statement for the last ShapeButton control instance
> (which is the first one created)
> 
> Thanks
> 
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


Ian Fear
Fear Consulting Ltd
1427 Te Kopia Rd
RD 1
Rotorua
New Zealand
Phone 64 7 333 2548
Fax 64 7 333 2548
mob 025 742 772
[EMAIL PROTECTED]
GMT +1200

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to