开发者

Is it safe to remove the IDE-created form variable?

I have a form called MyFor开发者_StackOverflow社区m stored in a unit called Unit UnitMyFrom. Of course Delphi automatically added this code:

TYPE
  TMyForm = class(TForm)
  private
  public
 end;

var MyForm: TMyForm;

but I removed the var declaration from that unit. Somebody said that this may cause problems with the IDE. Is it true? Does the IDE require that variable?


EDIT:

The MyForm IS NOT automatically created. The user creates that form at runtime.


I don't use auto-create and I never use global variables containing form references. It works just fine.


Remove the line Application.CreateForm(TMyForm, MyForm); in project .dpr file and you wont have any problems.

If you dont create the form automatically, then you wont have any problems


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


Go to Project Options, and make sure the form is not automatically created. Then you can safely remove the form instance variable. (Otherwise, you'll just get a compiler error.)


You may want to maintain this line in the uses or contains clause in the dpr-file:

  Unit1 in 'Unit1.pas' {Form1};

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


i remove them & have worked that way for quite a while (i don't autocreate or use the variable for most forms).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜