DIAdem Help

Content Type
Programming Language
Current manual

Working with the Bar Manager

Working with the Bar Manager

Use the bar manager to expand the DIAdem interface in order to make it easier to access frequently used DIAdem functions or to access user-defined functions.

Before you can add user-defined functions to the DIAdem interface you must first define the buttons that are to execute the user commands when clicked. Depending on the task you can integrate these buttons directly in the existing toolbars, function bars, or function groups in DIAdem. You also can combine the new buttons in separate bars or combine them with existing DIAdem buttons and combine them in a separate bar. To integrate a user-defined bar in the DIAdem interface define a button which opens a sub-bar and then integrate this button in the DIAdem interface.

Complete the following steps to add a function group, which contains buttons for starting functions required by the user, to the function bar of DIAdem SCRIPT:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script.

  3. Copy the ICO files required in this example to the Resource folder.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    Dim sPathDocuments
    sPathDocuments = ProgramDrv & "Examples\Documents"
    Call ScriptInclude(sPathDocuments & "REPORT_Library")
    Call CheckAndCopyIconFiles(sPathDocuments)
  4. Create a new bar called MyBar. Delete all elements in this bar if the bar already exists.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    Dim oMyBar
    If not BarManager.Bars.Exists("MyBar") Then
      Set oMyBar = BarManager.Bars.Add("MyBar")
    Else
      Set oMyBar = BarManager.Bars("MyBar")
      Call oMyBar.UsedActionObjs.RemoveAll
    End If
  5. Define two buttons for the new bar. The first button is to execute the function required by the user. Assign to the button a graphic, a tooltip, and the VBS code that DIAdem executes when the user clicks the button. The message box call represents the function required by the user.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    Dim oButton
    If not BarManager.ActionObjs.Exists("MyButton_1") Then
      Set oButton = BarManager.ActionObjs.Add("MyButton_1","CustomButton")
      oButton.Picture = "expl_star_yellow_add.ico"
      oButton.Tooltip = "Starts User Command"
      oButton.OnClickCode.Code = "Call MsgBoxDisp(""User Function"")"
    Else
      Set oButton = BarManager.ActionObjs("MyButton_1")
    End If
  6. Add this first button to the new bar.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    Call oMyBar.UsedActionObjs.Add(oButton)
  7. Define the second button. The second button is a test button, which triggers a Reset function that undoes all changes of the DIAdem interface. Add this button to the new bar as well.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    If not BarManager.ActionObjs.Exists("MyButton_2") Then
      Set oButton = BarManager.ActionObjs.Add("MyButton_2","CustomButton")
      oButton.Picture = "expl_star_yellow_delete.ico"
      oButton.Tooltip = "Deletes Bar"
      oButton.OnClickCode.Code = "Call BarManager.Reset"
    Else
      Set oButton = BarManager.ActionObjs("MyButton_2")
    End If
    
    Call oMyBar.UsedActionObjs.Add(oButton)
  8. Add a button that opens the new bar to the function bar in DIAdem SCRIPT. To do so define a button that opens the new bar with the function required by the user.
    Enter or copy the following text into the script editor:

    VBScriptPython

     

    Dim oPopup
    If not BarManager.ActionObjs.Exists("MyPopup") Then
      Set oPopup = BarManager.ActionObjs.Add("MyPopup","CustomPopup")
      oPopup.Picture = "expl_star_yellow.ico"
      oPopup.Tooltip = "Custom Bar"
      oPopup.BarId = oMyBar.Id
    Else
      Set oPopup = BarManager.ActionObjs("MyPopup")
    End If
  9. Add the new button to the function bar in DIAdem SCRIPT.
    First determine the name of the function bar to be expanded. All bar manager objects must have a unique name. If you want to modify or to extend the bar elements of the DIAdem interface, you need the names of these objects. If you press <Ctrl-Shift> and idle the cursor on a bar element, DIAdem displays a tooltip with the name of the bar, the name of the bar element, and the name of the base object or base type. DIAdem also copies this information, separated by a space, to the clipboard. The DIAdem SCRIPT function bar is called SCRGroup.

    Enter or copy the following text into the script editor:

    VBScriptPython

     

    If not BarManager.Bars("SCRGroup").UsedActionObjs.Exists(oPopup) Then
      Call BarManager.Bars("SCRGroup").UsedActionObjs.Add(oPopup)
    End If
  10. Click Run Script on the toolbar to test the script.
    The DIAdem SCRIPT group bar now contains an additional function group:
    Select Starts User Command to start the representative user command.
    Select Deletes Bar to remove the new function group from the DIAdem SCRIPT group bar.

Was this information helpful?

Previous

Bar Manager

Previous

Bar Manager