CreateToolbar
 
 
 

CreateToolbar

Description

Creates a new toolbar. You can add buttons on your toolbar with the CreateToolbarButton command and tweak its appearance by adding controls (such as line separators, cascading menus, etc.) with the CreateToolbarControl command.

Scripting Syntax

oString = CreateToolbar( Name );

Return Value

Returns a unique identifier String for the new toolbar.

Parameters

Parameter Type Description
Name String Name of the new toolbar.

Examples

1. VBScript Example

sub Install()
        dim file, toolbar, command, path
        path = Application.InstallationPath( siUserPath )
        file = path & "\Data\Scripts\myUtils.vbs"
        'Create Toolbar
        toolbar = CreateToolbar("Utilities")
        'Create Commands
        command = CreateScriptCommand( "Simplify It" ,_
                                        "makeSimple" ,_
                                        file ,_
                                        "MakeSimple",_
                                        "Makes life easier." )
        'Add button to toolbar.
        CreateToolbarButton toolbar, command
end sub

2. JScript Example

// This example illustrates how to use the self-installing plugins to 
// create a toolbar.
function XSILoadPlugin( in_reg )
{
        in_reg.Author = "YourName";
        in_reg.Name = "MyToolbarPlugin";
        in_reg.Major = 1;
        in_reg.Minor = 1;
        in_reg.RegisterCommand( "Create My Toolbar", "CreateMyToolbar" );
        if ( ! ToolBar_Exists("My Toolbar") )
                CreateMyToolbar_Execute(0);
        return true;
}
function CreateMyToolbar_Execute( in_arg0 )
{
        var uidToolbar = CreateToolbar( "My Toolbar" );
        var uidCmd = Commands("Info Scene").UID;
        CreateToolbarButton( uidToolbar, uidCmd );
        return true;
}
function ToolBar_Exists(name)
{
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var folderspec = Application.InstallationPath(siUserPath);
        folderspec = fso.BuildPath( folderspec, "Data" );
        folderspec = fso.BuildPath( folderspec, "Preferences" );
        folderspec = fso.BuildPath( folderspec, "Toolbars" );
        var folder = fso.GetFolder(folderspec);
        var eFiles = new Enumerator( folder.files );
        var re = new RegExp(name,"i");
        for ( ; !eFiles.atEnd(); eFiles.moveNext() )
        {
                var f = eFiles.item();
                if ( f.path.search( re ) != -1 )
                        return true;
        }
        return false;
}

See Also

CreateToolbarButton CreateToolbarControl CreateScriptCommand