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/

Reply via email to