From 6de920d8ec786d05d6dfe0ad09969e9a31e9d5c7 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 3 Jul 2007 19:35:09 +0000 Subject: [PATCH] Move creation of CopyTableForm from application startup to a place where it's done on demand. --- packages/delphi10/heidisql.dpr | 1 - packages/delphi11/heidisql.dpr | 1 - packages/delphi6/heidisql.dpr | 1 - source/copytable.dfm | 2 ++ source/copytable.pas | 18 ++++++++++++++++-- source/main.pas | 2 +- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/delphi10/heidisql.dpr b/packages/delphi10/heidisql.dpr index e3335cb5..6f31d2d7 100644 --- a/packages/delphi10/heidisql.dpr +++ b/packages/delphi10/heidisql.dpr @@ -45,7 +45,6 @@ begin Application.Title := APPNAME; Application.CreateForm(TMainForm, MainForm); debug('perf: Main created.'); - Application.CreateForm(TCopyTableForm, CopyTableForm); debug('perf: CopyTable created.'); Application.CreateForm(TFormEditUser, FormEditUser); debug('perf: EditUser created.'); Application.CreateForm(TfrmSQLhelp, frmSQLhelp); debug('perf: frmSQLhelp created.'); diff --git a/packages/delphi11/heidisql.dpr b/packages/delphi11/heidisql.dpr index f37adc37..aa2f027b 100644 --- a/packages/delphi11/heidisql.dpr +++ b/packages/delphi11/heidisql.dpr @@ -45,7 +45,6 @@ begin Application.CreateForm(TMainForm, MainForm); debug('perf: Main created.'); - Application.CreateForm(TCopyTableForm, CopyTableForm); debug('perf: CopyTable created.'); Application.CreateForm(TFormEditUser, FormEditUser); debug('perf: EditUser created.'); Application.CreateForm(TfrmSQLhelp, frmSQLhelp); debug('perf: frmSQLhelp created.'); diff --git a/packages/delphi6/heidisql.dpr b/packages/delphi6/heidisql.dpr index 59b24907..e8afa481 100644 --- a/packages/delphi6/heidisql.dpr +++ b/packages/delphi6/heidisql.dpr @@ -36,7 +36,6 @@ begin Application.CreateForm(Tconnform, connform); Application.CreateForm(TFieldEditForm, FieldEditForm); Application.CreateForm(TUserManagerForm, UserManagerForm); - Application.CreateForm(TCopyTableForm, CopyTableForm); Application.CreateForm(TFormEditUser, FormEditUser); Application.Run; end. diff --git a/source/copytable.dfm b/source/copytable.dfm index ccda0dd3..462e682d 100644 --- a/source/copytable.dfm +++ b/source/copytable.dfm @@ -92,6 +92,7 @@ object CopyTableForm: TCopyTableForm Anchors = [akRight, akBottom] Cancel = True Caption = 'Cancel' + ModalResult = 2 TabOrder = 5 OnClick = ButtonCancelClick end @@ -123,6 +124,7 @@ object CopyTableForm: TCopyTableForm Anchors = [akRight, akBottom] Caption = 'OK' Default = True + ModalResult = 1 TabOrder = 8 OnClick = ButtonOKClick end diff --git a/source/copytable.pas b/source/copytable.pas index 7f041208..da6d337a 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -39,8 +39,7 @@ type { Public declarations } end; -var - CopyTableForm: TCopyTableForm; + function CopyTableWindow(AOwner: TComponent): Boolean; const OPTION_UNDEFINED = 255; @@ -56,6 +55,21 @@ uses helpers, main, childwin, db; {$R *.DFM} +{** + Create form on demand + @param TComponent Owner of form (should be calling form) + @return Boolean Form closed using modalresult mrOK +} +function CopyTableWindow(AOwner: TComponent): Boolean; +var + f : TCopyTableForm; +begin + f := TCopyTableForm.Create(AOwner); + Result := (f.ShowModal=mrOK); + FreeAndNil(f); +end; + + procedure TCopyTableForm.radioStructureClick(Sender: TObject); begin radioStructureAndData.Checked := not radioStructure.Checked; diff --git a/source/main.pas b/source/main.pas index d97d37ca..64818929 100644 --- a/source/main.pas +++ b/source/main.pas @@ -796,7 +796,7 @@ end; procedure TMainForm.CopyTableExecute(Sender: TObject); begin // copy table - CopyTableForm.ShowModal; + CopyTableWindow(self); end;