📄 sstoreutils.pas
字号:
unit sStoreUtils;
{$I sDefs.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ToolWin, ComCtrls, ExtCtrls, ActnList, StdCtrls, jpeg, sStyleUtil,
sConst, Menus, sPanel, inifiles, sUtils, registry,
sEdit,
{$IFNDEF ALITE}
sCurrencyEdit, sCustomComboBox, sPageControl, sComboEdit, sMemo, sRadioButton,
{$ENDIF}
{$IFDEF USEDB}db, dbgrids, {$ENDIF}
sCheckBox, sCheckedControl,
sGraphUtils, buttons , sStyleEdits
{$IFDEF EHLIB}, DBGridEH{$ENDIF};
//<<<<<<<<<<<<<<<<<<<<< Work with Windows system and ini <<<<<<<<<<<<<<
function ReadRegString(Key : integer; Section, Named : string):string;
procedure WriteRegString(Section, Named, Value:string);
function ReadIniInteger(Section, Named: string; Value : integer; FileName: string): integer; overload;
function ReadIniInteger(Section, Named: string; Value : integer; r: TMemIniFile): integer; overload;
function ReadIniString(Section, Named, FileName: string):string; overload;
function ReadIniString(Section, Named: string; r: TMemIniFile):string; overload;
procedure ReadIniStrings(Value : TStrings; Section, Named, FileName: string); overload;
procedure ReadIniStrings(Value : TStrings; Section, Named: string; r: TMemIniFile); overload;
procedure WriteIniStr(Section, Named, Value, FileName:string); overload;
procedure WriteIniStr(Section, Named, Value:string; IniFile : TMemIniFile); overload;
procedure WriteIniStrings(Section, Named, FileName : string; Value : TStrings); overload;
procedure WriteIniStrings(Section, Named : string; Value : TStrings; IniFile : TMemIniFile); overload;
{$IFDEF EHLIB}
procedure SaveOurGrid(IniFileName: string; Grid:TDBGridEh);
procedure RestoreOurGrid(IniFileName: string; Grid:TDBGridEH);
{$ENDIF}
procedure RestoreCaptions(Form: TForm; IniFileName: string);
procedure SaveCaptions(Form: TForm; IniFileName: string);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
procedure SaveFormPlacement(Form: TForm; IniFileName: string);
procedure RestoreFormPlacement(Form: TForm; IniFileName: string);
implementation
uses sStyleSimply;
//const
// aWindowStates : array [0..2] of TWindowState = (wsNormal, wsMinimized, wsMaximized);
function ReadIniString(Section, Named, FileName: string):string;
var
r : TIniFile;
s : string;
begin
// s:='';
r := TIniFile.Create(FileName);
try
s := r.ReadString(Section,Named,'');
finally
r.Free;
end;
Result := s;
end;
function ReadIniString(Section, Named: string; r: TMemIniFile) : string;
var
s : string;
begin
try
s := r.ReadString(Section, Named, '');
finally
end;
Result := s;
end;
procedure ReadIniStrings(Value : TStrings; Section, Named, FileName: string); overload;
var
r : TMemIniFile;
begin
r := TMemIniFile.Create(FileName);
try
ReadIniStrings(Value, Section, Named, r);
finally
r.Free;
end;
end;
procedure ReadIniStrings(Value : TStrings; Section, Named: string; r: TMemIniFile); overload;
var
i, c : integer;
begin
c := ReadIniInteger(Section, Named + 'Count', 0, r);
if c = 0 then Exit;
Value.Clear;
for i := 0 to c - 1 do begin
Value.Add(ReadIniString(Section, Named + 'Item' + IntToStr(i), r));
end;
end;
function ReadIniInteger(Section, Named: string; Value : integer; FileName: string): integer;
var
r: TIniFile;
s: string;
begin
Result := -1;
r := TIniFile.Create(FileName);
try
s := r.ReadString(Section,Named, '');
finally
r.Free;
end;
try
if s = '' then Result := Value else Result := StrToInt(s);
except
end;
end;
function ReadIniInteger(Section, Named: string; Value : integer; r: TMemIniFile): integer; overload;
var
s: string;
begin
Result := -1;
if Assigned(r) then begin
s := r.ReadString(Section,Named, '');
try
if s = '' then Result := Value else Result := StrToInt(s);
except
end;
end;
end;
function ReadRegString(Key:integer; Section, Named:string):string;
var
r : TRegIniFile;
begin
Result := '';
r := TRegIniFile.Create('');
r.RootKey := Key;
try
Result := r.ReadString(Section, Named, '');
finally
r.Free;
end;
end;
procedure WriteRegString(Section, Named, Value:string);
var
r : TRegIniFile;
begin
r := TRegIniFile.Create('');
r.RootKey := HKEY_LOCAL_MACHINE;
try
r.CreateKey(Section);
r.WriteString(Section, Named, Value);
finally
r.Free;
end;
end;
procedure WriteIniStr(Section, Named, Value, FileName:string); overload;
var
r : TIniFile;
begin
r := TIniFile.Create(FileName);
try
if r <> nil then r.WriteString(Section,Named,Value);
finally
r.Free;
end;
end;
procedure WriteIniStr(Section, Named, Value:string; IniFile : TMemIniFile);
begin
try
IniFile.WriteString(Section, Named, Value);
finally
end;
end;
procedure WriteIniStrings(Section, Named, FileName : string; Value : TStrings); overload;
var
r : TMemIniFile;
begin
r := TMemIniFile.Create(FileName);
try
if r <> nil then WriteIniStrings(Section, Named, Value, r);
finally
r.Free;
end;
end;
procedure WriteIniStrings(Section, Named : string; Value : TStrings; IniFile : TMemIniFile); overload;
var
i : integer;
begin
WriteIniStr(Section, Named + 'Count', IntToStr(Value.Count), IniFile);
for i := 0 to Value.Count - 1 do begin
WriteIniStr(Section, Named + 'Item' + IntToStr(i), Value[i], IniFile);
end;
end;
{$IFDEF EHLIB}
procedure SaveOurGrid(IniFileName: string; Grid:TDBGridEH);
//var
// i : integer;
// f: TCustomForm;
// IniFile : TIniFile;
begin
Grid.SaveColumnsLayoutIni(IniFileName, 'T' + GetParentForm(Grid).Name, False);
// Exit;
{
f := GetParentForm(Grid);
IniFile := TIniFile.Create(IniFileName);
try
for i := 0 to Grid.Columns.Count - 1 do begin
WriteIniStr('T' + f.Name + Grid.Name,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -