You can create ActiveX add-ins to provide additional features to PowerDesigner, and call them through menu items.
HRESULT Initialize([in] IDispatch * pApplication) and HRESULT Uninitialize() - The Initialize() method initializes communication between PowerDesigner and the add-in. PowerDesigner provides a pointer to its application object, defined in the PdCommon type library, which allows you to access the PowerDesigner environment (output window, active model etc.). The Uninitialize() method is called when PowerDesigner is closed to release all global variables and clean all references to PowerDesigner objects.
BSTR ProvideMenuItems([in] BSTR sMenu, [in] IDispatch *pObj) - is invoked each time PowerDesigner needs to display a menu, and returns an XML text that describes the menu items to display. It is called once without an object parameter at the initialization of PowerDesigner to fill the Import and Reverse menus. 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.
<!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>For example:
ProvideMenuItems ("Object", pModel)returns the following text:
<Menu> <Popup Caption="&Perforce"> <Command Name="CheckIn" Caption="Check &In"/> <Separator/> <Command Name="CheckOut" Caption="Check &Out"/> </POPUP> </MENU>
BOOL IsCommandSupported([in] BSTR sMenu, [in] IDispatch * pObject, [in] BSTR sCommandName) - 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 ("Object", pModel, "CheckIn")