devexpress 动态调用皮肤

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
UseSkin:=false;
end;

你可能感兴趣的:(DevExpress)