WinSkinReg.pas
资源名称:winskin.rar [点击查看]
上传用户:lmk588
上传日期:2013-04-16
资源大小:5120k
文件大小:3k
源码类别:
按钮控件
开发平台:
Delphi
- unit WinSkinReg;
- interface
- {$I Compilers.Inc}
- uses Dialogs, Forms, Classes, SysUtils,
- {$ifdef DELPHI_4}
- DsgnIntf,
- {$endif DELPHI_4}
- {$ifdef DELPHI_5}
- DsgnIntf,
- {$endif DELPHI_5}
- {$ifdef DELPHI_6}
- DesignIntf,DesignEditors,
- {$endif DELPHI_6}
- {$ifdef DELPHI_7}
- DesignIntf,DesignEditors,
- {$endif DELPHI_7}
- {$ifdef CPPB_5}
- DsgnIntf,
- {$endif CPPB_5}
- {$ifdef CPPB_6}
- DesignIntf,DesignEditors,
- {$endif CPPB_6}
- winskindata,skinread,winsubclass,winskinform,WinSkinStore;
- procedure Register;
- implementation
- type
- { TWinSkinStore}
- TWinSkinStore = class(TPropertyEditor)
- private
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- function GetValue: string; override;
- end;
- procedure TWinSkinStore.Edit;
- var
- skindata: TSkindata; //ms
- storeitem: TSkinCollectionItem; //ms
- OpenDialog: TOpenDialog;
- begin
- { Execute editor }
- OpenDialog := TOpenDialog.Create(Application);
- OpenDialog.Filter := 'Skin files (*.skn)|*.skn';
- try
- if OpenDialog.Execute then
- begin
- { this entire block by ms }
- storeitem := nil;
- skindata := nil;
- if GetComponent(0) is TSkinCollectionItem then
- storeitem := GetComponent(0) as TSkinCollectionItem;
- if GetComponent(0) is TSkindata then
- skindata := GetComponent(0) as TSkindata;
- if storeitem <> nil then
- begin
- storeitem.LoadFromFile(OpenDialog.FileName);
- end
- else
- if skindata <> nil then
- begin
- skindata.data.clear;
- skindata.data.LoadFromFile(OpenDialog.FileName);
- skindata.SkinFile := '';
- end;
- {
- TSkindata(GetComponent(0)).data.clear;
- TSkindata(GetComponent(0)).data.LoadFromFile(OpenDialog.FileName);
- TSkindata(GetComponent(0)).SkinFile := '';
- }
- end;
- Modified;
- finally
- OpenDialog.Free;
- end;
- end;
- function TWinSkinStore.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog];
- end;
- function TWinSkinStore.GetValue: string;
- var
- skindata: TSkindata; //ms
- storeitem: TSkinCollectionItem; //ms
- begin
- // ms
- storeitem := nil;
- skindata := nil;
- if GetComponent(0) is TSkinCollectionItem then
- storeitem := GetComponent(0) as TSkinCollectionItem;
- if GetComponent(0) is TSkindata then
- skindata := GetComponent(0) as TSkindata;
- if storeitem <> nil then
- begin
- if storeitem.DataSize > 0 then
- Result := '(SkinData)'
- else
- Result := '(Empty)'
- end;
- if skindata <> nil then
- begin
- if TSkindata(GetComponent(0)).data.size > 0 then
- // Result := '('+TSeSkinEngine(GetComponent(0)).SkinSource.SkinName+')'
- Result := '(SkinData)'
- else
- Result := '(Empty)'
- end;
- end;
- procedure Register;
- begin
- RegisterComponents('VCLSkin', [TSkinData, TSkinStore]);
- RegisterPropertyEditor(TypeInfo(String), TSkinData, 'SkinStore',TWinSkinStore);
- // ms
- RegisterPropertyEditor(TypeInfo(String), TSkinCollectionItem, 'SkinData',TWinSkinStore);
- end;
- end.