RegisterOLECommand Method (CommandsManager Object)

Scope: Schematic editor

Object: CommandsManager Object

Prerequisites: None

Defines a new command line command.

Usage

CommandsManager.RegisterOLECommand(ByVal CommandName As String, ByVal CommandDescription As String, ByVal bModifiesData As Boolean, ByVal pDispatch As Object) As Boolean

Arguments

CommandName

This is the unique name for the command.

CommandDescription

This is a description of the command function that will appear when there is a help query.

bModifiesData

A value of True indicates that this command modifies data. This causes the application to lock the schematic or symbol before executing the command.

pDispatch

Client object which gets invoked when the command is executed. When the command is issued: If the object has a method called OnExecuteCommand, it will be passed the Application object's dispatch pointer, the value of the CommandName parameter, and the parameters passed to the command as a string like this:

OnExecuteCommand(pViewDrawApp, Command, RestOfLine)

Otherwise, the Object's method named the same as the CommandName parameter will be called like this:

CommandName(RestOfLine)

Return Values

As Boolean. True - The command was successfully registered. False - The command could not be registered.

Description

This method enables you to add your own commands to the command line. Command names must be unique and descriptions should be clear. If the command modifies the active block data bModifiesData should be True. You must also pass an Object (dispatch pointer) to your automation entry point that performs the command.

Examples

C++ Command Handler Prototype and Scripting.

C++ 
 
   void CMyApp::OnExecuteCommand(LPDISPATCH pViewDrawApp, LPCTSTR Command, LPCTSTR RestOfLine) 
   { 
 
   } 
 
VBSCRIPT 
 
   RegisterOLECommand "foo", "Foo displays a message box", False, ScriptEngine 
 
   Sub Foo(RestOfLine) 
       MsgBox "Foo Command Executed, RestOfLine=" & RestOfLine 
   End Sub