Is it safe to delete the form variable created by the IDE?

I have a MyForm form which is stored in Unit UnitMyFrom module. Of course, Delphi automatically added this code:

TYPE TMyForm = class(TForm) private public end; var MyForm: TMyForm; 

but I removed the var declaration from this block. Someone said that this could cause problems with the IDE. It's true? Does the IDE need this variable?


EDIT:

MyForm is NOT automatically created. The user creates this form at runtime.

+6
forms delphi
source share
6 answers

I do not use auto-creation, and I never use global variables that contain links to the form. It works great.

+13
source share

Delete the line Application.CreateForm(TMyForm, MyForm); in the .dpr project file and you won't have a problem.

If you do not create the form automatically, then you will not have a problem.

+7
source share

I would say yes when you want to automatically create a form because you need to pass this variable to the TApplication.CreateForm method.

+3
source share

Go to the "Project Settings" section and make sure that the form is not created automatically. Then you can safely remove the form instance variable. (Otherwise, you will get a compiler error.)

+3
source share

You can save this line to uses or contains in the dpr file:

  Unit1 in 'Unit1.pas' {Form1}; 

If you (or the IDE) deleted the {Form1} comment, your form will not appear in the list Shift+F12 - only in Ctrl+F12 -list.

+2
source share

I delete them and worked for a long time (I do not autorecord or use this variable for most forms).

+1
source share

All Articles