Creating an ActiveX Add-in

You can create your own menu items in PowerDesigner menus by creating an ActiveX add-in.

Note: To use your add-in, save it to the Add-ins directory beneath your PowerDesigner installation directory and enable it through the PowerDesigner General Options window (see Core Features Guide > The PowerDesigner Interface > Customizing Your Modeling Environment > General Options > Managing Add-Ins).

The ActiveX must implement a specific interface called IPDAddIn to become a PowerDesigner add-in.

This interface defines the following methods:

Those methods are invoked by PowerDesigner in order to dialog with menus and execute the commands defined by the ActiveX.

Initialize / Uninitialize Method

The Initialize method initializes the communication between PowerDesigner and the ActiveX. PowerDesigner starts the communication by providing the ActiveX with a pointer to its application object. The application object allows you to handle the PowerDesigner environment (output window, active model etc.) and must be saved for later reference. The application object type is defined into the PdCommon type library.

The Uninitialize method is used to clean references to PowerDesigner objects. It is called when PowerDesigner is closed and must be used to release all global variables.

ProvideMenuItems Method

The ProvideMenuItems method returns an XML text that describes the menu items to add into PowerDesigner menus. The method is invoked each time PowerDesigner needs to display a menu.

When you right-click a symbol in a diagram, this method is called twice: once for the object and once for the symbol. Thus, you can create a method that is only called on graphical contextual menus.

The ProvideMenuItems is called once at the initialization of PowerDesigner to fill the Import and Reverse menus. No object is put in parameter in the method at this moment.

The XML text that describes a menu can use the following elements (DTD):

<!ELEMENT Menu (Command | Separator | Popup)*>
<!ELEMENT Command>
<!ATTLIST Command
	Name	CDATA	#REQUIRED
	Caption	CDATA	#REQUIRED
>
<!ELEMENT Separator>
<!ELEMENT PopUp (Command | Separator | Popup)*>
<!ATTLIST PopUp
	Caption	CDATA	#REQUIRED
>

Example:

ProvideMenuItems ("Object", pModel)

The following text results:

<MENU>
<POPUP Caption="&Perforce">
	<COMMAND Name="CheckIn" Caption="Check &In"/>
	<SEPARATOR/>
	<COMMAND Name="CheckOut" Caption="Check &Out"/>
</POPUP>  
</MENU>

Note: This syntax is the same used in the creation of a menu using a resource file.

Note:

You can use the interface of the resource editor to visualize in the XML page the syntax of a menu you created in the Menu page that will help you construct the same XML syntax.

For more information on how to customize menus using a resource file, see Adding Commands and Other Items to Your Menu.

IsCommandSupported Method

The IsCommandSupported method allows you to dynamically disable commands defined in a menu. The method must return true to enable a command and false to disable it.

DoCommand Method

The DoCommand method implements the execution of a command designated by its name.

Example:

DoCommand ("Object", pModel, "CheckIn")