dxSkinController动态调入皮肤
摘自:http://hi.baidu.com/brainsoft/blog/item/580446386372de2996ddd850.html/cmtid/f1a341d0dfc1cb81a1ec9c31
dxSkinController可以在运行时动态调入皮肤,不用在设计期Use一大串文件,把要用的皮肤用安装程序自带的Skin Editor编辑一个SkinRes文件,然后在程序中动态调入就可以了。
uses dxSkinsDefaultPainters;
procedure TForm1.FormCreate(Sender: TObject);
begin
cxComboBox1.Properties.Items.Clear;
dxSkinsUserSkinPopulateSkinNames(ExtractFilePath(ParamStr(0))+'\bsSkins.skinres',
cxComboBox1.Properties.Items);
cxComboBox1.ItemIndex:=0;
end;
procedure TForm1.cxComboBox1PropertiesChange(Sender: TObject);
begin
//这个地方必须是UserSkin,不然不会起作用
dxSkinController1.SkinName:='UserSkin';
dxSkinsUserSkinLoadFromFile(ExtractFilePath(ParamStr(0))+'\bsSkins.skinres',cxComboBox1.EditText);
end;
procedure TForm1.dxSkinController1SkinForm(Sender: TObject;
AForm: TCustomForm; var ASkinName: String; var UseSkin: Boolean);
begin
uses dxSkinsDefaultPainters;
procedure TForm1.FormCreate(Sender: TObject);
begin
cxComboBox1.Properties.Items.Clear;
dxSkinsUserSkinPopulateSkinNames(ExtractFilePath(ParamStr(0))+'\bsSkins.skinres',
cxComboBox1.Properties.Items);
cxComboBox1.ItemIndex:=0;
end;
procedure TForm1.cxComboBox1PropertiesChange(Sender: TObject);
begin
//这个地方必须是UserSkin,不然不会起作用
dxSkinController1.SkinName:='UserSkin';
dxSkinsUserSkinLoadFromFile(ExtractFilePath(ParamStr(0))+'\bsSkins.skinres',cxComboBox1.EditText);
end;
procedure TForm1.dxSkinController1SkinForm(Sender: TObject;
AForm: TCustomForm; var ASkinName: String; var UseSkin: Boolean);
begin
//Simon自己认为这一句不应该要,要了窗口就不能跟着变,而且dxSkinController要在所有cx控件添加前添加,否则控件皮肤不受拜你控制。
UseSkin:=false;
end;
UseSkin:=false;
end;
Simon补充:
在Developer Express.VCL的安装目录下,文件夹Developer Express.VCL\ExpressSkins Library\Binary Skin Files 中包含有Developer Express 自带的控件皮肤资源包,可以把全部皮肤资源包“AllSkins.skinres”Copy 到工程文件目录中,以进行调用,
但有一个问题现在还不知道,就是dxBarPopuMenu的皮肤怎么受控制的?现在研究中!