我要做一个管理软件,里面有个主窗体,然后是很多子窗体,如果我一运行的话全部都初始化的话,是不是很费内存,能不能每点一个按钮打开一个子窗口,每点一个按钮就关闭当前活动的子窗体,再打开新窗体呢.给个例子看看好吗
[email protected]

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
       form2:TForm2;
    begin
       form2:=Tform2.Create(nil);
       try
         form2.ShowModal;
       finally
        FreeAndNil(form2);
       end;end;
      

  2.   

    delphi menu
    project/option.../forms
    auto-create form 中把除首要FORM外不用的FORM都去掉.其余的按照上边那位老兄说的就可以.
      

  3.   

    比较详细的例子,请看
    http://www.resbbs.com/dispbbs.asp?boardID=9&ID=147
      

  4.   

    首先同:Eric_Su(扬春) 
    var
      FrmMain: TFrmMain;
      FMenu: TSeSkinItem;
      NewChildClass: TFormClass;
      NewChildForm: TForm;
    ......implementationprocedure TFrmMain.ItemClick(Sender: TObject);
    begin  if Assigned(NewChildForm) then
      begin
        try
          NewChildForm.Free;
          NewChildForm :=nil;
        finally
          FMenu.Enabled := True;
        end;
      end;  case (Sender as TSeSkinItem).tag of
        11: NewChildClass := TFrmCarInfo;
        12: NewChildClass := TFrmDriverInfo;
        13: NewChildClass := TFrmMasterInfo;    21: NewChildClass := TFrmTax;
        22: NewChildClass := TFrmInsurance;    31: NewChildClass := TFrmPeccancy;
        32: NewChildClass := TFrmAccident;
        33: NewChildClass := TFrmRePair;
        34: NewChildClass := TFrmLearn;
        35: NewChildClass := TFrmFeedBack;    41: NewChildClass := TFrmCarQuery;
        42: NewChildClass := TFrmDriverQuery;
        43: NewChildClass := TFrmMasterQuery;
        44: NewChildClass := TFrmInsuranceQuery;
        45: NewChildClass := TFrmTaxQuery;
        46: NewChildClass := TFrmPeccQuery;
        47: NewChildClass := TFrmAccidentQuery;
        48: NewChildClass := TFrmRepairQuery;
        49: NewChildClass := TFrmLearnQuery;    51: NewChildClass := TFrmCarPrint;
        52: NewChildClass := TFrmDriverPrint;
        53: NewChildClass := TFrmMasterPrint;
        54: NewChildClass := TFrmCarAgent;
        55: NewChildClass := TFrmCarTransfer;
        56: NewChildClass := TFrmTaxPrint;
        57: NewChildClass := TFrmPeccPrint;    511:NewChildClass := TFrmCarNotePrint;    61: NewChildClass := TFrmRules;    71: NewChildClass := TFrmBaseTable;
        72: NewChildClass := TFrmSysInit;
        73: NewChildClass := TFrmprivilageSet;
        74: NewChildClass := TFrmpayRuleSet;
        75: NewChildClass := TFrmDBBackup;
      else
        NewChildClass := nil;
      end;  if Assigned(NewChildClass) then
      begin
        NewChildForm := NewChildClass.Create(Application);
        with NewChildForm do
        try
          Hint := AppTitle;
          BorderStyle := bsNone;
          BorderIcons := [];
          Parent := Self.Panel1;
          WindowState := wsMaxiMized;
          Align := alClient;
          Show;
        finally
          FMenu := Sender as TSeSkinItem;
          FMenu.Enabled := False;
        end;
      end;
      Self.Caption := AppTitle + '¹ÜÀíϵͳ -> ' + NewChildForm.Caption;
    end;