delphi 一定要指定mainForm吗? delphi 一定要指定mainForm吗? 

解决方案 »

  1.   

    打开Prj的代码,然后打开菜单的Project->Option->Forms,看Auto Created Form 和Available Form跟Main Form的相互关系,再对照Prj文件的源码变化就清楚了
      

  2.   

    在Delphi程序运行时一定会有一个MainForm的,如果没有自己指定,则工程文件里第一个创建的窗体被指定为MainForm.
      

  3.   

    看你开发什么程序,Application的话一般都有MainForm。
      

  4.   


    procedure TApplication.CreateForm(InstanceClass: TComponentClass; var Reference);
    var
      Instance: TComponent;
    begin
      Instance := TComponent(InstanceClass.NewInstance);
      TComponent(Reference) := Instance;
      try
        Instance.Create(Self);
      except
        TComponent(Reference) := nil;
        raise;
      end;
      if (FMainForm = nil) and (Instance is TForm) then
      begin
        TForm(Instance).HandleNeeded;
        FMainForm := TForm(Instance);
      end;
    end;
      if (FMainForm = nil) and (Instance is TForm) then
      begin
        TForm(Instance).HandleNeeded;
        FMainForm := TForm(Instance);
      end;其实就是这句在起作用,如果你用CreateForm创建窗体,如果当前主窗体为nil的话,则把当前创建的窗体指定为主窗体。如果你用TForm.Create则不会指定。
      

  5.   


      dim a as string
      a="string"
      msgbox a