Initialization

As every DynAPI project the DynAPI interface is initialized with the following code:

// First of all we need to initialize the DynAPI
dmbAPI_Init();


  Sample #1
Here's an image being used as a hotspot to trigger a menu created with DHTML Menu Builder. Then we will call some DynAPI functions to add a new command and change the caption of one of the commands that already existed on the attached group.


Attached group: grpMyGroup
Created with DHTML Menu Builder.
A new command is added dynamically using the DynAPI
The second command's caption is changed using the DynAPI

Here's the code used to perform the above functions:

// This variable is used to hold the reference to newly created commands
var nc;

// Create a new command, and store a reference to it in "nc"
nc = dmbAPI_addCommand("grpMyGroup", "Link to xfx.net");

// Change the item's color:
dmbAPI_setColor(nc, "#FF0000", "", "#00FF00", "#000000");

// Change the item's font and style:
dmbAPI_setFont(nc, "Tahoma|B|N|N", "Tahoma|B|N|U", 9);

// Set the OnClick event to the new command
dmbAPI_setOnClick(nc, "http://www.xfx.net");

// Change the caption of the "Command 02" command.
dmbAPI_setCaption(dmbAPI_getItemByCaption("Command 02"), "Caption Changed");

// Assign a right image (an arrow) to indicate that the menu item will display a submenu.
dmbAPI_setImageRightNormal(nc, "images/ablack.gif", 11, 12);
dmbAPI_setImageRightOver(nc, "images/awhite.gif", 11, 12);


  Sample #2

Attached group: grpNewGroup
Created dynamically with DynAPI
Three commands are added dynamically using the DynAPI

Here's the code used to perform the above functions:

// Create a new group
dmbAPI_addGroup("grpNewGroup");

// Add three commands to the new group
dmbAPI_addCommand("grpNewGroup", "Another Command 01");
dmbAPI_addCommand("grpNewGroup", "Another Command 02");
dmbAPI_addCommand("grpNewGroup", "Another Command 03");

// Set the onmouseover event for the "Caption Changed" command
// to display the "grpNewGroup" group as a submenu
dmbAPI_setOnMouseOver(dmbAPI_getItemByCaption("Caption Changed"), "grpNewGroup", "", true, 6);