From 79c95bd9fda258eb599fb6a01be8ffc4c4c1cfe6 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 3 Jul 2007 20:22:49 +0000 Subject: [PATCH] Move creation of SQLhelp from application startup to a place where it's done on demand. Move public property keyword to the private context as it is no longer accessed from outside. --- packages/delphi10/heidisql.dpr | 2 -- packages/delphi11/heidisql.dpr | 2 -- source/childwin.pas | 3 +-- source/sqlhelp.dfm | 1 + source/sqlhelp.pas | 21 ++++++++++++++++++--- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/delphi10/heidisql.dpr b/packages/delphi10/heidisql.dpr index 0f4c8d31..0d8bc725 100644 --- a/packages/delphi10/heidisql.dpr +++ b/packages/delphi10/heidisql.dpr @@ -45,8 +45,6 @@ begin Application.Title := APPNAME; Application.CreateForm(TMainForm, MainForm); debug('perf: Main created.'); - Application.CreateForm(TfrmSQLhelp, frmSQLhelp); debug('perf: frmSQLhelp created.'); - try try diff --git a/packages/delphi11/heidisql.dpr b/packages/delphi11/heidisql.dpr index 2d0d06ab..f768fa7e 100644 --- a/packages/delphi11/heidisql.dpr +++ b/packages/delphi11/heidisql.dpr @@ -45,8 +45,6 @@ begin Application.CreateForm(TMainForm, MainForm); debug('perf: Main created.'); - Application.CreateForm(TfrmSQLhelp, frmSQLhelp); debug('perf: frmSQLhelp created.'); - try try diff --git a/source/childwin.pas b/source/childwin.pas index 8d457176..b6239b98 100644 --- a/source/childwin.pas +++ b/source/childwin.pas @@ -4290,8 +4290,7 @@ end; procedure TMDIChild.CallSQLHelpWithKeyword( keyword: String ); begin // Set help-keyword and show window - frmSQLhelp.keyword := keyword; - frmSQLhelp.Show; + SQLhelpWindow(self, keyword); end; procedure TMDIChild.ToolButton4Click(Sender: TObject); diff --git a/source/sqlhelp.dfm b/source/sqlhelp.dfm index 712fca13..df9be615 100644 --- a/source/sqlhelp.dfm +++ b/source/sqlhelp.dfm @@ -202,6 +202,7 @@ object frmSQLhelp: TfrmSQLhelp Cancel = True Caption = 'Close' Default = True + ModalResult = 1 TabOrder = 1 OnClick = ButtonCloseClick end diff --git a/source/sqlhelp.pas b/source/sqlhelp.pas index 72a9541d..5c8a02b3 100644 --- a/source/sqlhelp.pas +++ b/source/sqlhelp.pas @@ -40,9 +40,9 @@ type private { Private declarations } m : TMDIChild; + Keyword: String; public { Public declarations } - Keyword: String; end; const @@ -51,8 +51,7 @@ type ICONINDEX_CATEGORY_OPENED : Integer = 97; ICONINDEX_HELPITEM : Integer = 98; -var - frmSQLhelp : TfrmSQLhelp; + function SQLhelpWindow(AOwner: TComponent; Keyword: String = ''): Boolean; implementation @@ -64,6 +63,22 @@ uses ZDataset, helpers, main, db; +{** + Create form on demand + @param TComponent Owner of form (should be calling form) + @return Boolean Form closed using modalresult mrOK +} +function SQLhelpWindow(AOwner: TComponent; Keyword: String = ''): Boolean; +var + f : TfrmSQLhelp; +begin + f := TfrmSQLhelp.Create(AOwner); + f.Keyword := Keyword; + Result := (f.ShowModal=mrOK); + FreeAndNil(f); +end; + + {*** Startup }