bazzer747 25 Posted January 10, 2020 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. Share this post Link to post
bazzer747 25 Posted January 10, 2020 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
dummzeuch 1505 Posted January 10, 2020 Try to spot these: fViewSignups:= tfViewSignups( Self ); Also quite difficult. Share this post Link to post
Mark Williams 14 Posted January 10, 2020 I make that error quite often. I've often wondered why the compiler doesn't pick it up. Share this post Link to post
Guest Posted January 10, 2020 Or: FSomeClass := TSomeClass(Owner); No warning, just mayhem. Share this post Link to post
Mark Williams 14 Posted January 10, 2020 And TMyObject(SL[index]).Something Where SL is a TStrings. If I had a dollar for every time... Share this post Link to post