source: components/VCLSkin.v4.04.For.D7/WinSkinReg.pas

Last change on this file was 1, checked in by maron, 16 years ago

3.1 verze, první revize

File size: 3.0 KB
Line 
1unit WinSkinReg;
2
3interface
4
5{$I Compilers.Inc}
6
7uses 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
30procedure Register;
31
32implementation
33
34
35type
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
45procedure TWinSkinStore.Edit;
46var
47 skindata: TSkindata; //ms
48 storeitem: TSkinCollectionItem; //ms
49
50 OpenDialog: TOpenDialog;
51begin
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;
90end;
91
92function TWinSkinStore.GetAttributes: TPropertyAttributes;
93begin
94 Result := [paDialog];
95end;
96
97function TWinSkinStore.GetValue: string;
98var
99 skindata: TSkindata; //ms
100 storeitem: TSkinCollectionItem; //ms
101begin
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
129end;
130
131procedure Register;
132begin
133 RegisterComponents('VCLSkin', [TSkinData, TSkinStore, TSkinCaption]);
134 RegisterPropertyEditor(TypeInfo(String), TSkinData, 'SkinStore',TWinSkinStore);
135
136 // ms
137 RegisterPropertyEditor(TypeInfo(String), TSkinCollectionItem, 'SkinData',TWinSkinStore);
138
139end;
140
141end.
142
Note: See TracBrowser for help on using the repository browser.