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.
File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.