Changeset 133 for trunk/Packages/Common


Ignore:
Timestamp:
Mar 4, 2022, 10:57:08 PM (3 years ago)
Author:
chronos
Message:
  • Added: Compile multiple action for compilation of code with mutliple compilers at once.
Location:
trunk/Packages/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UCommon.pas

    r129 r133  
    88  {$IFDEF WINDOWS}Windows,{$ENDIF}
    99  {$IFDEF UNIX}baseunix,{$ENDIF}
    10   Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf,
     10  Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, Graphics,
    1111  FileUtil; //, ShFolder, ShellAPI;
    1212
    1313type
    1414  TArrayOfByte = array of Byte;
    15   TArrayOfString = array of string;
    1615  TExceptionEvent = procedure(Sender: TObject; E: Exception) of object;
    1716
     
    3534  DLLHandle1: HModule;
    3635
     36const
     37  clLightBlue = TColor($FF8080);
     38  clLightGreen = TColor($80FF80);
     39  clLightRed = TColor($8080FF);
     40
    3741{$IFDEF WINDOWS}
    3842  GetUserNameEx: procedure (NameFormat: DWORD;
     
    5155function ComputerName: string;
    5256procedure DeleteFiles(APath, AFileSpec: string);
     57function Explode(Separator: Char; Data: string): TStringArray;
    5358procedure ExecuteProgram(Executable: string; Parameters: array of string);
    5459procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);
     
    6570function LoadFileToStr(const FileName: TFileName): AnsiString;
    6671function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    67 function MergeArray(A, B: array of string): TArrayOfString;
     72function MergeArray(A, B: array of string): TStringArray;
    6873function OccurenceOfChar(What: Char; Where: string): Integer;
    6974procedure OpenWebPage(URL: string);
     75procedure OpenEmail(Email: string);
    7076procedure OpenFileInShell(FileName: string);
    7177function PosFromIndex(SubStr: string; Text: string;
     
    8389function SplitString(var Text: string; Count: Word): string;
    8490function StripTags(const S: string): string;
    85 function TryHexToInt(Data: string; var Value: Integer): Boolean;
    86 function TryBinToInt(Data: string; var Value: Integer): Boolean;
     91function TryHexToInt(Data: string; out Value: Integer): Boolean;
     92function TryBinToInt(Data: string; out Value: Integer): Boolean;
    8793procedure SortStrings(Strings: TStrings);
    8894
     
    246252end;
    247253
    248 function TryHexToInt(Data: string; var Value: Integer): Boolean;
     254function TryHexToInt(Data: string; out Value: Integer): Boolean;
    249255var
    250256  I: Integer;
     
    262268end;
    263269
    264 function TryBinToInt(Data: string; var Value: Integer): Boolean;
     270function TryBinToInt(Data: string; out Value: Integer): Boolean;
    265271var
    266272  I: Integer;
     
    290296end;
    291297
    292 function Explode(Separator: char; Data: string): TArrayOfString;
    293 begin
    294   Result := nil;
    295   SetLength(Result, 0);
    296   while Pos(Separator, Data) > 0 do begin
     298function Explode(Separator: Char; Data: string): TStringArray;
     299var
     300  Index: Integer;
     301begin
     302  Result := Default(TStringArray);
     303  repeat
     304    Index := Pos(Separator, Data);
     305    if Index > 0 then begin
     306      SetLength(Result, Length(Result) + 1);
     307      Result[High(Result)] := Copy(Data, 1, Index - 1);
     308      Delete(Data, 1, Index);
     309    end else Break;
     310  until False;
     311  if Data <> '' then begin
    297312    SetLength(Result, Length(Result) + 1);
    298     Result[High(Result)] := Copy(Data, 1, Pos(Separator, Data) - 1);
    299     Delete(Data, 1, Pos(Separator, Data));
    300   end;
    301   SetLength(Result, Length(Result) + 1);
    302   Result[High(Result)] := Data;
    303 end;
    304 
    305 {$IFDEF Windows}
     313    Result[High(Result)] := Data;
     314  end;
     315end;
     316
     317{$IFDEF WINDOWS}
    306318function GetUserName: string;
    307319const
     
    311323begin
    312324  L := MAX_USERNAME_LENGTH + 2;
     325  Result := Default(string);
    313326  SetLength(Result, L);
    314327  if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin
     
    324337  end;
    325338end;
    326 {$endif}
     339{$ENDIF}
    327340
    328341function ComputerName: string;
    329 {$ifdef mswindows}
     342{$IFDEF WINDOWS}
    330343const
    331344 INFO_BUFFER_SIZE = 32767;
     
    342355  end;
    343356end;
    344 {$endif}
    345 {$ifdef unix}
     357{$ENDIF}
     358{$IFDEF UNIX}
    346359var
    347360  Name: UtsName;
     
    351364  Result := Name.Nodename;
    352365end;
    353 {$endif}
    354 
    355 {$ifdef windows}
     366{$ENDIF}
     367
     368{$IFDEF WINDOWS}
    356369function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    357370const
     
    431444procedure LoadLibraries;
    432445begin
    433   {$IFDEF Windows}
     446  {$IFDEF WINDOWS}
    434447  DLLHandle1 := LoadLibrary('secur32.dll');
    435448  if DLLHandle1 <> 0 then
     
    442455procedure FreeLibraries;
    443456begin
    444   {$IFDEF Windows}
     457  {$IFDEF WINDOWS}
    445458  if DLLHandle1 <> 0 then FreeLibrary(DLLHandle1);
    446459  {$ENDIF}
     
    475488end;
    476489
     490procedure OpenEmail(Email: string);
     491begin
     492  OpenURL('mailto:' + Email);
     493end;
     494
    477495procedure OpenFileInShell(FileName: string);
    478496begin
     
    503521end;
    504522
    505 function MergeArray(A, B: array of string): TArrayOfString;
    506 var
    507   I: Integer;
    508 begin
    509   Result := Default(TArrayOfString);
     523function MergeArray(A, B: array of string): TStringArray;
     524var
     525  I: Integer;
     526begin
     527  Result := Default(TStringArray);
    510528  SetLength(Result, Length(A) + Length(B));
    511529  for I := 0 to Length(A) - 1 do
  • trunk/Packages/Common/ULastOpenedList.pas

    r102 r133  
    8484destructor TLastOpenedList.Destroy;
    8585begin
    86   Items.Free;
     86  FreeAndNil(Items);
    8787  inherited;
    8888end;
     
    9494begin
    9595  if Assigned(MenuItem) then begin
    96     MenuItem.Clear;
     96    while MenuItem.Count > Items.Count do
     97      MenuItem.Delete(MenuItem.Count - 1);
     98    while MenuItem.Count < Items.Count do begin
     99      NewMenuItem := TMenuItem.Create(MenuItem);
     100      MenuItem.Add(NewMenuItem);
     101    end;
    97102    for I := 0 to Items.Count - 1 do begin
    98       NewMenuItem := TMenuItem.Create(MenuItem);
    99       NewMenuItem.Caption := Items[I];
    100       NewMenuItem.OnClick := ClickAction;
    101       MenuItem.Add(NewMenuItem);
     103      MenuItem.Items[I].Caption := Items[I];
     104      MenuItem.Items[I].OnClick := ClickAction;
    102105    end;
    103106  end;
  • trunk/Packages/Common/UTheme.pas

    r122 r133  
    4141    property Theme: TTheme read FTheme write SetTheme;
    4242  end;
     43
     44const
     45  ThemeNameSystem = 'System';
     46  ThemeNameLight = 'Light';
     47  ThemeNameDark = 'Dark';
    4348
    4449procedure Register;
     
    105110  inherited;
    106111  Themes := TThemes.Create;
    107   with Themes.AddNew('System') do begin
     112  with Themes.AddNew(ThemeNameSystem) do begin
    108113    ColorWindow := clWindow;
    109114    ColorWindowText := clWindowText;
     
    113118  end;
    114119  Theme := TTheme(Themes.First);
    115   with Themes.AddNew('Dark') do begin
     120  with Themes.AddNew(ThemeNameDark) do begin
    116121    ColorWindow := RGBToColor($20, $20, $20);
    117122    ColorWindowText := clWhite;
     
    120125    ColorControlSelected := RGBToColor(96, 125, 155);
    121126  end;
    122   with Themes.AddNew('Light') do begin
     127  with Themes.AddNew(ThemeNameLight) do begin
    123128    ColorWindow := clWhite;
    124129    ColorWindowText := clBlack;
     
    175180procedure TThemeManager.UseTheme(Form: TForm);
    176181begin
    177   if not Used and (FTheme.Name = 'System') then Exit;
     182  if not Used and (FTheme.Name = ThemeNameSystem) then Exit;
    178183  ApplyTheme(Form);
    179184  Used := True;
Note: See TracChangeset for help on using the changeset viewer.