Ticket K18293
Visible to All Users

How to load skins dynamically

created 15 years ago

Description:
This article describes how to load skins dynamically by using .SKINRES files

Answer:
First of all, it is necessary to save your skin project, containing one or more Skins, in a single .SKINRES file. For additional information on how to create your own skin project, please refer to the "How to Create Skins Using the Skin Editor" help topic and related topics.
Then you can populate any list of the TStrings type with your custom skins' names. This list will allow you to display available skin names in an appropriate control/editor (for example, TcxComboBox). To accomplish this, you can call the dxSkinsUserSkinPopulateSkinNames function as follows:

Delphi
dxSkinsUserSkinPopulateSkinNames(AFileName, AComboBox.Properties.Items);

After that, you can handle the editor's OnEditValueChanged event (or any other event that indicates that the control's current value is changed) to change the current skin according to the name selected in the control. In this event, it is necessary to load the corresponding skin from your .SKINRES file (use the dxSkinsUserSkinLoadFromFile method to accomplish this task), set the dxSkinController's SkinName property value to 'UserSkin', and call the dxSkinController's Refresh method. You can also change the dxRibbon's color scheme the same way. Just set the Ribbon.ColorSchemeName property value to 'UserSkin'.

You can find a small demo project demonstrating how to use our TcxComboBox to load a skin dynamically. Alternatively, you can use any other control you wish.

Comments (2)

    Is there any particular reason to set SkinName to 'UserSkin' ?
    I tried to set SkinName to cxCombobox1.Text and it works too
    what's the difference between 'UserSkin' and .Text ?
    In My case, i want to use different skin for form and control.
    For example :
    form skin = office2013white ===> set from dxSkinController1 ===>comboboxFormSkin
    control skin = office2010blue ===> set from dxLayoutSkinLookAndFeel1 ===>comboboxControlSkin
    my controls are inside dxLayoutControl with dxLayoutControl's LookAndFeel set to dxLayoutSkinLookAndFeel1
    in comboboxFormSkin onPropertiesEditValueChange :
    dxSkinController1.SkinName := 'UserSkin'
    in comboboxControlSkin onPropertiesEditValueChange :
    dxLayoutSkinLookAndFeel1.LookAndFeel.SkinName:='UserSkin'
    when I choose skin from comboboxControlSkin, "both" form and control skin changed to the selected skin
    and after that, even comboboxFormSkin will also change control skin (comboboxFormSkin works correctly if comboboxControlSkin's value is not changed yet)
    the correct behavior is : comboboxFormSkin will change form skin, and comboboxControlSkin change control skin
    this behavior is achieved correctly with SkinName := combobox(form / control)skin.Text
    why it is not achieved with SkinName := 'UserSkin' ?
    thank you

    DevExpress Support Team 10 years ago

      Hello,

      To process your recent post more efficiently, I created a separate ticket on your behalf: T234373: Is there any particular reason to set SkinName to UserSkin?. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.