HowTo: XP Theme support

roger_74 wrote on 4/19/2004, 12:12 PM
Now that Vegas supports Windows XP themes we can use it in our scripts too. But the FlatStyle property has to be set for Buttons and GroupBoxes (others too?), so here is a function that takes care of that. I found it in a newsgroup and converted it to JScript.NET.

function SetFlatStyleSystem(parent : Control)
{
    for (var control : Control in parent.Controls)
    {
        var button : ButtonBase = null;
        var group : GroupBox = null;

        if(control instanceof ButtonBase)
            button = ButtonBase(control);
        if(control instanceof GroupBox)
            group = GroupBox(control);

        if (button != null)
            button.FlatStyle = FlatStyle.System;
        else if (group != null)
            group.FlatStyle = FlatStyle.System;

        SetFlatStyleSystem(control);
    }
}

Run the function at the end of your form class, like this: SetFlatStyleSystem(this);
Tested on the scripts that are included in V5.

Of course, you can set FlatStyle = FlatStyle.System directly, but this is a nice shortcut for existing scripts.

Comments

No comments yet - be the first to write a comment...