Skip to content

Execute - cCJAction

This triggers an action's execute process, causing OnExecute to be sent.

Type: Procedure

Parameters

Parameter Type Description
vCommandBarControl Variant Pointer to the COM control that was executed. If used, this must be bound to a DataFlex proxy object, which should be based cCJCommandBarControl or one if its sub-classes. This is rarely needed.

Syntax

Procedure Execute Variant vCommandBarControl

Call Example

Send Execute vCommandBarControl

Description

Any time you execute an item by clicking on the item with a mouse or by navigating to the item and pressing the Enter key, the Execute message is sent to the object that was selected. This causes the OnExecute event to be sent. OnExecute is the event that should be used to perform whatever execute behavior you want for an action. Normally, the object that receives the message will be based on cCJMenuItem class or one of its sub-classes. These are sub-classes of cCJAction class. The Execute logic for these classes is defined here.

The Execute Process

Execute does the following:

  1. Execute first verifies that that action's item is enabled by calling IsEnabled. If not, it returns and does nothing.

  2. If it is enabled, it calls OnExecute. This is the event that should be augmented to perform the custom execution.

  3. It thens sends Update, which will reset pbEnabled, pbChecked and pbVisible as needed. It does this by calling IsEnabled, IsChecked and IsVisible and setting the corresponding properties.

As long as you place the proper code within IsEnabled that checks if it is appropriate to execute a menu item for a particular focused object you never have to worry about adding code to OnExecute to check for this. Also, as long as you place all code to determine an action's checked, enabled and visible state within the IsChecked, IsEnabled and IsVisible functions, any changes in an item's state will be updated automatically at the end of the execute process.

Execute and PopupInit

Execute is called when your menu or toolbar item is a non-popup item. If your menu or toolbar item is a popup item, a private PopupInit message in the cCJCommandBarSystem class is sent instead (see OnPopupInit for a description of this process). An item's type is controlled by the control's peControlType property.

Usage

You will rarely augment this message.

You may send this message to manually trigger the execution of an item. If you do this, you should send a null vCommandBarControl parameter ( NullComObject() )and you should make sure that your OnExecute is capable of handing this Null parameter. Usually OnExecute does not use the passed parameter, so this is not an issue.

// Execute the save item
Send Execute of oSaveMenuItem (NullComObject())

See Also

OnExecute