-
Notifications
You must be signed in to change notification settings - Fork 5
/
VssIniFiles.pas
73 lines (60 loc) · 1.58 KB
/
VssIniFiles.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit VssIniFiles;
interface
uses Classes,INIFiles, NumUtils, Graphics, Windows;
type
TVssMemIniFile = class(TMemIniFile)
public
procedure LoadFromStream(Stream: TStream);
function ReadRGBColor(const Section, Ident: string;Default: Tcolor): Tcolor;
function ReadRGBAColor(const Section, Ident: string;Default: TRGBQuad): TRGBQuad;
procedure WriteRGBColor(const Section, Ident: string; Value: TColor);
procedure WriteRGBAColor(const Section, Ident: string; Value: TRGBQuad);
end;
implementation
{ TVssMemIniFile }
function TVssMemIniFile.ReadRGBAColor(const Section, Ident: string;
Default: TRGBQuad): TRGBQuad;
var
ReadStr: string;
begin
ReadStr := ReadString(Section, Ident, ''); //88
try
Result := StringRGBAToRGBA(ReadStr);
except
Result := Default;
end;
end;
function TVssMemIniFile.ReadRGBColor(const Section, Ident: string;
Default: Tcolor): Tcolor;
var
ReadStr: string;
begin
ReadStr := ReadString(Section, Ident, '');
try
Result := StringRGBToColor(ReadStr);
except
Result := Default;
end;
end;
procedure TVssMemIniFile.WriteRGBAColor(const Section, Ident: string; Value: TRGBQuad);
begin
WriteString(Section, Ident, RGBAToStringRGBA(Value));
end;
procedure TVssMemIniFile.WriteRGBColor(const Section, Ident: string;
Value: TColor);
begin
WriteString(Section, Ident, ColorToStringRGB(Value));
end;
procedure TVssMemIniFile.LoadFromStream(Stream: TStream);
var
sl : TStringList;
begin
sl:=TStringList.Create;
try
sl.LoadFromStream(Stream);
SetStrings(sl);
finally
sl.Free;
end;
end;
end.