1 | unit WinSkinReg;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | {$I Compilers.Inc}
|
---|
6 |
|
---|
7 | uses Dialogs, Forms, Classes, SysUtils,
|
---|
8 | {$ifdef DELPHI_4}
|
---|
9 | DsgnIntf,
|
---|
10 | {$endif DELPHI_4}
|
---|
11 |
|
---|
12 | {$ifdef DELPHI_5}
|
---|
13 | DsgnIntf,
|
---|
14 | {$endif DELPHI_5}
|
---|
15 |
|
---|
16 | {$ifdef DELPHI_6_UP}
|
---|
17 | DesignIntf,DesignEditors,
|
---|
18 | {$endif DELPHI_6}
|
---|
19 |
|
---|
20 | {$ifdef CPPB_5}
|
---|
21 | DsgnIntf,
|
---|
22 | {$endif CPPB_5}
|
---|
23 |
|
---|
24 | {$ifdef CPPB_6}
|
---|
25 | DesignIntf,DesignEditors,
|
---|
26 | {$endif CPPB_6}
|
---|
27 |
|
---|
28 | winskindata,skinread,winsubclass,winskinform,WinSkinStore,SkinCaption;
|
---|
29 |
|
---|
30 | procedure Register;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 |
|
---|
35 | type
|
---|
36 | { TWinSkinStore}
|
---|
37 | TWinSkinStore = class(TPropertyEditor)
|
---|
38 | private
|
---|
39 | public
|
---|
40 | procedure Edit; override;
|
---|
41 | function GetAttributes: TPropertyAttributes; override;
|
---|
42 | function GetValue: string; override;
|
---|
43 | end;
|
---|
44 |
|
---|
45 | procedure TWinSkinStore.Edit;
|
---|
46 | var
|
---|
47 | skindata: TSkindata; //ms
|
---|
48 | storeitem: TSkinCollectionItem; //ms
|
---|
49 |
|
---|
50 | OpenDialog: TOpenDialog;
|
---|
51 | begin
|
---|
52 | { Execute editor }
|
---|
53 | OpenDialog := TOpenDialog.Create(Application);
|
---|
54 | OpenDialog.Filter := 'Skin files (*.skn)|*.skn';
|
---|
55 | try
|
---|
56 | if OpenDialog.Execute then
|
---|
57 | begin
|
---|
58 |
|
---|
59 | { this entire block by ms }
|
---|
60 | storeitem := nil;
|
---|
61 | skindata := nil;
|
---|
62 |
|
---|
63 | if GetComponent(0) is TSkinCollectionItem then
|
---|
64 | storeitem := GetComponent(0) as TSkinCollectionItem;
|
---|
65 |
|
---|
66 | if GetComponent(0) is TSkindata then
|
---|
67 | skindata := GetComponent(0) as TSkindata;
|
---|
68 |
|
---|
69 | if storeitem <> nil then
|
---|
70 | begin
|
---|
71 | storeitem.LoadFromFile(OpenDialog.FileName);
|
---|
72 | end
|
---|
73 | else
|
---|
74 | if skindata <> nil then
|
---|
75 | begin
|
---|
76 | skindata.data.clear;
|
---|
77 | skindata.data.LoadFromFile(OpenDialog.FileName);
|
---|
78 | skindata.SkinFile := '';
|
---|
79 | end;
|
---|
80 | {
|
---|
81 | TSkindata(GetComponent(0)).data.clear;
|
---|
82 | TSkindata(GetComponent(0)).data.LoadFromFile(OpenDialog.FileName);
|
---|
83 | TSkindata(GetComponent(0)).SkinFile := '';
|
---|
84 | }
|
---|
85 | end;
|
---|
86 | Modified;
|
---|
87 | finally
|
---|
88 | OpenDialog.Free;
|
---|
89 | end;
|
---|
90 | end;
|
---|
91 |
|
---|
92 | function TWinSkinStore.GetAttributes: TPropertyAttributes;
|
---|
93 | begin
|
---|
94 | Result := [paDialog];
|
---|
95 | end;
|
---|
96 |
|
---|
97 | function TWinSkinStore.GetValue: string;
|
---|
98 | var
|
---|
99 | skindata: TSkindata; //ms
|
---|
100 | storeitem: TSkinCollectionItem; //ms
|
---|
101 | begin
|
---|
102 |
|
---|
103 | // ms
|
---|
104 | storeitem := nil;
|
---|
105 | skindata := nil;
|
---|
106 |
|
---|
107 | if GetComponent(0) is TSkinCollectionItem then
|
---|
108 | storeitem := GetComponent(0) as TSkinCollectionItem;
|
---|
109 |
|
---|
110 | if GetComponent(0) is TSkindata then
|
---|
111 | skindata := GetComponent(0) as TSkindata;
|
---|
112 |
|
---|
113 | if storeitem <> nil then
|
---|
114 | begin
|
---|
115 | if storeitem.DataSize > 0 then
|
---|
116 | Result := '(SkinData)'
|
---|
117 | else
|
---|
118 | Result := '(Empty)'
|
---|
119 | end;
|
---|
120 |
|
---|
121 | if skindata <> nil then
|
---|
122 | begin
|
---|
123 | if TSkindata(GetComponent(0)).data.size > 0 then
|
---|
124 | Result := '(SkinData)'
|
---|
125 | else
|
---|
126 | Result := '(Empty)'
|
---|
127 | end;
|
---|
128 |
|
---|
129 | end;
|
---|
130 |
|
---|
131 | procedure Register;
|
---|
132 | begin
|
---|
133 | RegisterComponents('VCLSkin', [TSkinData, TSkinStore, TSkinCaption]);
|
---|
134 | RegisterPropertyEditor(TypeInfo(String), TSkinData, 'SkinStore',TWinSkinStore);
|
---|
135 |
|
---|
136 | // ms
|
---|
137 | RegisterPropertyEditor(TypeInfo(String), TSkinCollectionItem, 'SkinData',TWinSkinStore);
|
---|
138 |
|
---|
139 | end;
|
---|
140 |
|
---|
141 | end.
|
---|
142 |
|
---|