We recommend that you limit the number of items you add to the predefined Microsoft Dynamics GP toolbars. If you have more than one or two items to display on the toolbar, consider defining your own toolbar and adding the items to it.
Toolbar items are typically shortcuts to items defined in the application’s menus. Avoid adding toolbar items without a corresponding menu items. |
Microsoft Dynamics GP provides the AddCommandToCmdBar() global function that you will use to add commands to toolbars. Use the table in the section Toolbars in Microsoft Dynamics GP to find the form name and command list for the toolbar to which you want to add the command. You will also use the resourceid() function to look up the resource IDs of the command forms and commands.
For example, the following code adds the IG_Lead_Maintenance command to the end of the Sales toolbar.
Seq = 0; status = AddCommandToCmdBar(DYNAMICS, resourceid(form Command_System), resourceid(command Toolbar_Sales of form Command_System), Seq, IG_PROD_ID, resourceid(form Command_IG_Sample), resourceid(command IG_Lead_Maintenance of form Command_IG_Sample), true, MENULOAD_TOTABLE);
Notice that the resourceid() function is used to look up the resource IDs of the commands and command forms accessed, such as the Toolbar_Sales command and the Command_System form.
Separarators are a special built-in command that you can add to toolbars. Like other commands, you add them using the AddCommandToCmdBar() function. The following special constants are used to refer to the separator command:
Constant |
Description |
---|---|
CMD_BUILTINCMD_DICTID |
Specifies the ID of the dictionary that contains the separator built-in command. |
CMD_BUILTINCMD_FORMID |
Specifies the resource ID of the form that defines the separator built-in command. |
cmdSeparator |
The built-in separator command. |
For example, the following code adds a separator to the end of the Sales toolbar, defined by the Toolbar_Sales command list.
Seq = 0; Status = AddCommandToCmdBar(DYNAMICS, resourceid(form Command_System), resourceid(command Toolbar_Sales of form Command_System), Seq, CMD_BUILTINCMD_DICTID, CMD_BUILTINCMD_FORMID, resourceid(command cmdSeparator), true, MENULOAD_TOTABLE);