Chapter 4 Managing Profiles


Dialog box layout tools

These tools are only available when the form is a dialog box:

Tool Name

Adds an edit field below the selected item in the tree.

Adds a multi-line edit field below the selected item in the tree.

Adds a combo box below the selected item in the tree.

Adds a list box below the selected item in the tree.

Adds a check box below the selected item in the tree.

Example

In this example, you create a new dialog box with an edit field. This dialog box appears when you select the Export command in the contextual menu of the extended object metaclass. You use this dialog box to type the path where the extended object should be exported.

To create this dialog box form you have to:

  1. Right-click the ExtendedObject metaclass in the resource editor and select New→Form.
  2. Type Export in the Name box, and type a comment in the Comment box. Make sure the Dialog box type is selected.
  3. Click the Add Edit Field tool to add an edit field in the form tree view, you can name it Filename.
  4. Right-click the ExtendedObject metaclass in the resource editor and select New→Method. This creates a new method, you can call it Export.
  5. Click the Method Script tab and type the following code:

Sub %Method%(obj)
   ' Exports an object in a file
   
   ' Create a dialog to input the export file name
   Dim dlg
   Set dlg = obj.CreateCustomDialog("MyProfile.Export")
   If not dlg is Nothing Then
      
      ' Initialize filename control
      dlg.SetValue "Filename", "c:\temp\MyFile.txt"
      
      ' Show dialog
      If dlg.ShowDialog() Then
         
         ' Retrieve customer value for filename control
         Dim filename
         filename = dlg.GetValue("Filename")
         
         ' Process the export algorithm...
         Output "Exporting object " + obj.Name + " to file " + filename
         
      End If
      
      ' Free dialog object
      dlg.Delete
      Set dlg = Nothing
      
   End If
   
End Sub

SetValue initializes the edit field, and GetValue uses the path defined in the dialog box.

  1. Right-click the ExtendedObject metaclass in the resource editor and select New→Menu. This creates a new menu, you can call it Export menu.
  2. Click the Add Commands from Methods and Transformations tool and select the Export method you have created.
  3. Click OK in the resource editor.
  4. Right-click an extended object in the current diagram and select the Export command in the contextual menu.

    The Export dialog box appears with the Filename edit field.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.