troubleshooting Question

Create and destroy components

Avatar of zagarz
zagarz asked on
Programming Languages-OtherDelphiPascal
7 Comments1 Solution798 ViewsLast Modified:
---call form
    frmKalibStan:=TfrmKalibStan.Create(Self);
    frmKalibStan.Inicializiraj(True, dmGarnitura.qryGKalGlID_KGL.AsInteger);
    frmKalibStan.Caption:='Kalibracija merila: standardno merilo';
    PotrebnoOsveziti:= frmKalibStan.ShowModal = mrOk;

works fine
then random crash
 access violation error
or
abstract error
procedure TfrmKalibGladka.AddNewButton;
var
  (* Pointer to the new button that we are going to create *)
  NovKnof : TcxButton;
  i : Integer;
begin
with dmMetrologija do begin
         if qryKalGlOU.AsInteger = 10 then begin
            actOU.ImageIndex := 2
            end
            else begin
            actOU.ImageIndex := -1;
         end;
end;
 
For i :=0 to ComponentCount -1 do
  If (Components[i] is  TcxButton ) Then
  If ( TcxButton(Components[i]).Name='btnOU') Then
      NovKnof:=Nil;
     (TcxButton(Components[i]).Free);
      NovKnof := TcxButton.Create(Self);
  with NovKnof do
  begin
    Name := 'btnOU';
    Top    := 10;//Panel2.Top +  BtnOUK.Top + 1;
    Width  := 55;//BtnOUK.Width;
    Kind   := cxbkStandard;
    Left   := 10;//Ugotovitve.Left + BtnOUK.Left + 8;
    LookAndFeel.NativeStyle := True;
    Parent := self;
    Caption := 'OU';
    Action := actOU;
end;
end;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros