Ignore:
Timestamp:
Sep 10, 2022, 10:21:48 PM (20 months ago)
Author:
chronos
Message:
  • Modified: Do not create all application forms at initialization phase but dynamically.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormDatabases.pas

    r26 r28  
    4343  end;
    4444
    45 var
    46   FormDatabases: TFormDatabases;
    4745
    4846implementation
     
    5250uses
    5351  UCore, UFormConnect;
     52
     53resourcestring
     54  SRemoveDatabaseConnection = 'Remove database connection';
     55  SRemoveDatabaseConnectionQuery = 'Do you want to really remove database connection %s?';
     56  SNewDatabase = 'New database';
    5457
    5558{ TFormDatabases }
     
    7174begin
    7275  if Assigned(ListView1.Selected) then begin
    73     if MessageDlg('Remove database connection', 'Do you want to really remove database connection ' +
    74     TDbConnectProfile(ListView1.Selected.Data).Name, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
     76    if MessageDlg(SRemoveDatabaseConnection, Format(SRemoveDatabaseConnectionQuery, [
     77    TDbConnectProfile(ListView1.Selected.Data).Name]), mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    7578      Core.DbManager.ConnectProfiles.Remove(ListView1.Selected.Data);
    7679      ReloadList;
     
    8487begin
    8588  NewConnectProfile := TDbConnectProfile.Create;
    86   NewConnectProfile.Name := 'New database';
    87   FormConnect.Load(NewConnectProfile);
    88   if FormConnect.ShowModal = mrOk then begin
    89     FormConnect.Save(NewConnectProfile);
    90     Core.DbManager.ConnectProfiles.Add(NewConnectProfile);
    91     ReloadList;
    92   end else NewConnectProfile.Free;
     89  NewConnectProfile.Name := SNewDatabase;
     90  with TFormConnect.Create(nil) do
     91  try
     92    Load(NewConnectProfile);
     93    if ShowModal = mrOk then begin
     94      Save(NewConnectProfile);
     95      Core.DbManager.ConnectProfiles.Add(NewConnectProfile);
     96      ReloadList;
     97    end else NewConnectProfile.Free;
     98  finally
     99    Free;
     100  end;
    93101end;
    94102
     
    96104begin
    97105  if Assigned(ListView1.Selected) then begin
    98     FormConnect.Load(TDbConnectProfile(ListView1.Selected.Data));
    99     if FormConnect.ShowModal = mrOk then begin
    100       FormConnect.Save(TDbConnectProfile(ListView1.Selected.Data));
    101       ReloadList;
     106    with TFormConnect.Create(nil) do
     107    try
     108      Load(TDbConnectProfile(ListView1.Selected.Data));
     109      if ShowModal = mrOk then begin
     110        Save(TDbConnectProfile(ListView1.Selected.Data));
     111        ReloadList;
     112      end;
     113    finally
     114      Free;
    102115    end;
    103116  end;
Note: See TracChangeset for help on using the changeset viewer.