application.createform(txxx,xxx);
xxx.showmodal;
xxx.destroy;// xxx.free;

解决方案 »

  1.   

    我也是:
    application.createform(tform2,form2);
    form2.show;
    然后把所有form的控件都free掉,(包括最后form2.free),但是占用的内存一点都没减少
    WHY?
      

  2.   

    鼠标变成沙漏
    Screen.Cursor:=crHourGlass; 我动态创建窗体使用方法是
    var
      Form1:TForm1;
    begin
      Form1:=TForm1.Create(Application);
      Form1.ShowModal();
      Form1.Free();
    end;
    如果仍然慢,很有可能在FormOnCreate事件中有太多的事要做,可以分出去点。
    另外如果有连接数据库,那么是会慢的。
      

  3.   

    如果在Create或show事件中有太多的事要做,可以把这些事另外写在一个过程中。把这个过程交给一个线程来完成。你的窗口的速度就会很快了。
      

  4.   

    我来回答第二个问题:
    Var Mutex: THandle;
    begin
      Mutex:= CreateMutex(nil,true,'SingleApp');
      if GetLastError<>Error_Already_Exists then
      begin
        ...
        Application.CreateForm(Txxx,xxx);
        Application.Show();
        ...
      end
      else
      begin
        {给出提示说应用程序实例已经在运行}
      end;
      

  5.   

    第二个问题
    var
      AppWnd: HWND;
    begin
      AppWnd  := FindWindow('TApplication', 在此填入Application的Title如'hello' );
      if AppWnd <> 0 then //已有实例在运行
      begin
        if IsIconic(AppWnd) then ShowWindow(AppWnd, SW_RESTORE)
        else
          SetForegroundWindow(AppWnd);
        Exit;
      end;                                                           
      Application.Initialize;
      Application.Title := 'hello';
      Application.CreateForm(TMainForm, MainForm);
    ....