Changeset 75 for trunk/Forms


Ignore:
Timestamp:
Aug 2, 2016, 1:15:57 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Use option start minimized in system tray only in case of user logon.
Location:
trunk/Forms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r74 r75  
    124124    ProjectClosed: Boolean;
    125125    ImportTotalItemCount: Integer;
     126    function FindFirstNonOption: string;
    126127    procedure ProjectOpen(FileName: string);
    127128    procedure Initialize;
     
    442443end;
    443444
     445function TFormMain.FindFirstNonOption: string;
     446var
     447  S: string;
     448  I: Integer;
     449begin
     450  Result := '';
     451  for I := 1 to Application.ParamCount do begin
     452    S := Application.Params[I];
     453    if S[1] = Application.OptionChar then Continue;
     454    Result := S;
     455    Break;
     456  end;
     457end;
     458
    444459procedure TFormMain.ProjectOpen(FileName: string);
    445460begin
     
    458473
    459474procedure TFormMain.Initialize;
     475var
     476  FileNameOption: string;
    460477begin
    461478  if not Initialized then begin
     
    463480    LoadConfig;
    464481
    465     if StartMinimizedToTray then Visible := False;
    466 
    467     if ParamCount > 0 then begin
     482{$IFDEF 0}
     483    if Application.HasOption('h', 'help') then begin
     484      WriteLn('AcronymDecoder <project file>');
     485      WriteLn('  -t    --tray   Start minimized in system tray');
     486      WriteLn('  -h    --help  Show this help');
     487      Application.Terminate;
     488      Exit;
     489    end;
     490{$ENDIF}
     491    if Application.HasOption('t', 'tray') then begin
     492      Visible := False;
     493    end;
     494
     495    FileNameOption := FindFirstNonOption;
     496    if FileNameOption <> '' then begin
    468497      // Open file specified as command line parameter
    469       AcronymDB.LoadFromFile(ParamStr(1));
     498      AcronymDB.LoadFromFile(FileNameOption);
    470499      LastOpenedList1.AddItem(OpenDialog1.FileName);
    471500    end else
     
    640669    RootKey := HKEY_CURRENT_USER;
    641670    OpenKey(RegistryRunKey, True);
    642     if StartOnLogon then WriteString('Acronym Decoder', Application.ExeName)
    643       else DeleteValue('Acronym Decoder');
     671    if StartOnLogon then begin
     672      if StartMinimizedToTray then WriteString('Acronym Decoder', Application.ExeName + ' /t')
     673        else WriteString('Acronym Decoder', Application.ExeName)
     674    end else DeleteValue('Acronym Decoder');
    644675  finally
    645676    Free;
  • trunk/Forms/UFormSettings.lfm

    r70 r75  
    6262    Width = 150
    6363    Caption = 'Start on user logon'
     64    OnChange = CheckBoxStartOnLogonChange
    6465    TabOrder = 4
    6566  end
    6667  object CheckBoxStartMinimizedToTray: TCheckBox
    67     Left = 16
     68    Left = 48
    6869    Height = 24
    6970    Top = 128
  • trunk/Forms/UFormSettings.pas

    r70 r75  
    2222    Label1: TLabel;
    2323    procedure ButtonOkClick(Sender: TObject);
     24    procedure CheckBoxStartOnLogonChange(Sender: TObject);
    2425    procedure FormShow(Sender: TObject);
    2526  private
     
    2829    procedure Load;
    2930    procedure Save;
     31    procedure UpdateInterface;
    3032  end;
    3133
     
    5557end;
    5658
     59procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
     60begin
     61  UpdateInterface;
     62end;
     63
    5764procedure TFormSettings.Load;
    5865begin
     
    6067  CheckBoxStartOnLogon.Checked := FormMain.StartOnLogon;
    6168  CheckBoxStartMinimizedToTray.Checked := FormMain.StartMinimizedToTray;
     69  UpdateInterface;
    6270end;
    6371
     
    6977end;
    7078
     79procedure TFormSettings.UpdateInterface;
     80begin
     81  CheckBoxStartMinimizedToTray.Enabled := CheckBoxStartOnLogon.Checked;
     82end;
     83
    7184end.
    7285
Note: See TracChangeset for help on using the changeset viewer.