Changeset 74 for trunk/Packages/Common
- Timestamp:
- Dec 17, 2016, 6:33:13 PM (8 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UCommon.pas
r73 r74 6 6 7 7 uses 8 {$IFDEF Windows}Windows,{$ENDIF} 8 {$ifdef Windows}Windows,{$endif} 9 {$ifdef Linux}baseunix,{$endif} 9 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 10 11 FileUtil; //, ShFolder, ShellAPI; … … 69 70 function GetDirCount(Dir: string): Integer; 70 71 function MergeArray(A, B: array of string): TArrayOfString; 72 function LoadFileToStr(const FileName: TFileName): AnsiString; 71 73 72 74 … … 305 307 end; 306 308 end; 309 {$endif} 307 310 308 311 function ComputerName: string; … … 324 327 {$endif} 325 328 {$ifdef unix} 326 begin 327 Result := GetHostName; 329 var 330 Name: UtsName; 331 begin 332 fpuname(Name); 333 Result := Name.Nodename; 328 334 end; 329 335 {$endif} 330 336 337 {$ifdef windows} 331 338 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 332 339 const … … 443 450 444 451 procedure OpenWebPage(URL: string); 445 var446 Process: TProcess;447 Browser, Params: string;448 452 begin 449 453 OpenURL(URL); 450 {try451 Process := TProcess.Create(nil);452 Browser := '';453 //FindDefaultBrowser(Browser, Params);454 //Process.Executable := Browser;455 //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]);456 Process.CommandLine := 'cmd.exe /c start ' + URL;457 Process.Options := [poNoConsole];458 Process.Execute;459 finally460 Process.Free;461 end;}462 454 end; 463 455 … … 501 493 end; 502 494 495 function LoadFileToStr(const FileName: TFileName): AnsiString; 496 var 497 FileStream: TFileStream; 498 Read: Integer; 499 begin 500 Result := ''; 501 FileStream := TFileStream.Create(FileName, fmOpenRead); 502 try 503 if FileStream.Size > 0 then begin 504 SetLength(Result, FileStream.Size); 505 Read := FileStream.Read(Pointer(Result)^, FileStream.Size); 506 SetLength(Result, Read); 507 end; 508 finally 509 FileStream.Free; 510 end; 511 end; 512 503 513 504 514 -
trunk/Packages/Common/UPersistentForm.pas
r73 r74 8 8 9 9 uses 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry ;10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls; 11 11 12 12 type … … 19 19 FMinVisiblePart: Integer; 20 20 FRegistryContext: TRegistryContext; 21 procedure LoadControl(Control: TControl); 22 procedure SaveControl(Control: TControl); 21 23 public 22 24 FormNormalSize: TRect; … … 49 51 50 52 { TPersistentForm } 53 54 procedure TPersistentForm.LoadControl(Control: TControl); 55 var 56 I: Integer; 57 WinControl: TWinControl; 58 Count: Integer; 59 begin 60 if Control is TListView then begin 61 with Form, TRegistryEx.Create do 62 try 63 RootKey := RegistryContext.RootKey; 64 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True); 65 for I := 0 to TListView(Control).Columns.Count - 1 do begin 66 if ValueExists('ColWidth' + IntToStr(I)) then 67 TListView(Control).Columns[I].Width := ReadInteger('ColWidth' + IntToStr(I)); 68 end; 69 finally 70 Free; 71 end; 72 end; 73 74 if Control is TWinControl then begin 75 WinControl := TWinControl(Control); 76 if WinControl.ControlCount > 0 then begin 77 for I := 0 to WinControl.ControlCount - 1 do begin 78 if WinControl.Controls[I] is TControl then begin 79 LoadControl(WinControl.Controls[I]); 80 end; 81 end; 82 end; 83 end; 84 end; 85 86 procedure TPersistentForm.SaveControl(Control: TControl); 87 var 88 I: Integer; 89 WinControl: TWinControl; 90 begin 91 if Control is TListView then begin 92 with Form, TRegistryEx.Create do 93 try 94 RootKey := RegistryContext.RootKey; 95 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True); 96 for I := 0 to TListView(Control).Columns.Count - 1 do begin 97 WriteInteger('ColWidth' + IntToStr(I), TListView(Control).Columns[I].Width); 98 end; 99 finally 100 Free; 101 end; 102 end; 103 104 if Control is TWinControl then begin 105 WinControl := TWinControl(Control); 106 if WinControl.ControlCount > 0 then begin 107 for I := 0 to WinControl.ControlCount - 1 do begin 108 if WinControl.Controls[I] is TControl then begin 109 SaveControl(WinControl.Controls[I]); 110 end; 111 end; 112 end; 113 end; 114 end; 51 115 52 116 procedure TPersistentForm.LoadFromRegistry(RegistryContext: TRegistryContext); … … 181 245 Form.BoundsRect := FormNormalSize; 182 246 end; 247 LoadControl(Form); 183 248 end; 184 249 … … 191 256 FormWindowState := Form.WindowState; 192 257 SaveToRegistry(RegistryContext); 258 SaveControl(Form); 193 259 end; 194 260 -
trunk/Packages/Common/UScaleDPI.pas
r73 r74 309 309 end; 310 310 311 if Control is TCoolBar then 312 with TCoolBar(Control) do begin 313 BeginUpdate; 314 for I := 0 to Bands.Count - 1 do 315 with Bands[I] do begin 316 MinWidth := ScaleX(MinWidth, FromDPI.X); 317 MinHeight := ScaleY(MinHeight, FromDPI.Y); 318 Width := ScaleX(Width, FromDPI.X); 319 //Control.Invalidate; 320 end; 321 EndUpdate; 322 end; 323 311 324 if Control is TToolBar then begin 312 325 ToolBarControl := TToolBar(Control);
Note:
See TracChangeset
for help on using the changeset viewer.