Ignore:
Timestamp:
Jul 26, 2016, 5:48:35 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Main form was unexpectedly initialized and project reopened if main form was hidden to system tray and shown again.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r63 r64  
    119119    procedure TrayIcon1Click(Sender: TObject);
    120120  private
     121    Initialized: Boolean;
    121122    FAlwaysOnTop: Boolean;
    122123    RegistryContext: TRegistryContext;
    123124    ProjectClosed: Boolean;
    124125    ImportTotalItemCount: Integer;
     126    procedure Initialize;
    125127    procedure ProcessImportsJob(Job: TJob);
    126128    procedure SetAlwaysOnTop(AValue: Boolean);
     
    166168
    167169procedure TFormMain.FormCreate(Sender: TObject);
     170var
     171  I: Integer;
    168172begin
    169173  AcronymDb := TAcronymDb.Create;
     174  Initialized := False;
     175  for I := 0 to ToolBar1.ButtonCount - 1 do
     176    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
    170177end;
    171178
     
    362369
    363370procedure TFormMain.FormShow(Sender: TObject);
    364 var
    365   I: Integer;
    366 begin
    367   LoadConfig;
     371begin
     372  Initialize;
     373
    368374  PersistentForm1.Load(Self);
    369 
    370   if ParamCount > 0 then begin
    371     AcronymDB.LoadFromFile(ParamStr(1));
    372     LastOpenedList1.AddItem(OpenDialog1.FileName);
    373   end else
    374   if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then
    375     AcronymDB.LoadFromFile(LastOpenedList1.Items[0]);
    376   UpdateAcronymsList;
    377   ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    378   UpdateInterface;
    379   for I := 0 to ToolBar1.ButtonCount - 1 do
    380     ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     375  UpdateInterface;
    381376end;
    382377
     
    444439  Visible := not Visible;
    445440  if Visible then BringToFront;
     441end;
     442
     443procedure TFormMain.Initialize;
     444begin
     445  if not Initialized then begin
     446    Initialized := True;
     447    LoadConfig;
     448
     449    if ParamCount > 0 then begin
     450      AcronymDB.LoadFromFile(ParamStr(1));
     451      LastOpenedList1.AddItem(OpenDialog1.FileName);
     452    end else
     453    if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then
     454      AcronymDB.LoadFromFile(LastOpenedList1.Items[0]);
     455    UpdateAcronymsList;
     456    ListViewFilter1.UpdateFromListView(ListViewAcronyms);
     457  end;
    446458end;
    447459
Note: See TracChangeset for help on using the changeset viewer.