Jump to content
bazzer747

Component already exists

Recommended Posts

Hi

I've created a new Windows VCL application and on the first form I've added several buttons, each buttons click event opens a new form. Three of these forms are OK, I've added various components (buttons, navigators, grids etc) but on the last I opened has no components on it except a button (called btnClose) which simply closes the form.

 

However, when I run the application and press the button that opens this form I get an error message: 'A component named btnClose already exists'. After selecting the OK to this error, if I click the same button again the application freezes and I use Task Manager to kill it. If I click the other buttons, they open their forms fine, but if I then click on the 4th one again I get 'Invalid pointer operation'. This is the form in text:

 

object fViewSignups: TfViewSignups
  Left = 0
  Top = 0
  Caption = 'View Signups'
  ClientHeight = 299
  ClientWidth = 678
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btnClose: TRzButton
    Left = 520
    Top = 40
    Caption = 'Close'
    TabOrder = 0
    OnClick = btnCloseClick
  end
end

 

... no duplicate btnClose, also see attached screenshot. I created this form with:

 

procedure TfMain.RzButton2Click(Sender: TObject);
begin
    fViewSignups.Create( Self );
    try
      fViewSignups.Showmodal;
    finally
      fViewSignups.Free;
    end;
end;
 

Which is identical to the way I created the other 3 forms which all work OK. I've closed everthing down and restarted everything and can't think of anythging else to look at to see where or why this error is happening. This is the first Windows application I've created since upgrading to Delphi 10.3.3, which may be something.

 

Any thoughts on what else I can do would be appreciated.

 

 

btnCloseIssue.jpg

Share this post


Link to post

Arrgghhh! I've spotted the error. In the code I had 

fViewSignups.Create( Self );

 

Should be: fViewSignups:= tfViewSignups.Create( Self );

 

Silly type error, can't see the woods for the trees sometimes ... Works fine now.

Share this post


Link to post

Try to spot these:

 

fViewSignups:= tfViewSignups( Self );

 

Also quite difficult.

Share this post


Link to post
Guest

Or:

FSomeClass := TSomeClass(Owner);

No warning, just mayhem.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×