Share via


CommandTargetExec Event

Occurs when an Active Document host notifies an Active Document of the command to be executed.

PROCEDURE Object.CommandTargetExec
LPARAMETERS nCommandID, nExecOption, eArgIn, eArgOut

Parameters

  • nCommandID
    A parameter passed by the Active Document's host to the CommandTargetExec event that indicates the command to be executed. The following table lists the values passed to the event that Visual FoxPro can process and the corresponding command to be executed.

    nCommandID FOXPRO.H Constant Command
    1 CMDID_OPEN File menu Open command.
    2 CMDID_NEW File menu New command.
    3 CMDID_SAVE File menu Save command.
    4 CMDID_SAVEAS File menu Save As command.
    5 CMDID_SAVECOPYAS File menu Save Copy As command.
    6 CMDID_PRINT File menu Print command.
    7 CMDID_PRINTPREVIEW File menu Print Preview command.
    8 CMDID_PAGESETUP File menu Page Setup command.
    9 CMDID_SPELL Tools menu Spelling command.
    10 CMDID_PROPERTIES File menu Properties command.
    11 CMDID_CUT Edit menu Cut command.
    12 CMDID_COPY Edit menu Copy command.
    13 CMDID_PASTE Edit menu Paste command.
    14 CMDID_PASTESPECIAL Edit menu Paste Special command.
    15 CMDID_UNDO Edit menu Undo command.
    16 CMDID_REDO Edit menu Redo command.
    17 CMDID_SELECTALL Edit menu Select All command.
    18 CMDID_CLEARSELECTION Edit menu Clear command.
    19 CMDID_ZOOM View menu Zoom command.
    20 CMDID_GETZOOMRANGE Retrieves zoom range applicable to the View menu Zoom command.
    21 CMDID_UPDATECOMMANDS Notifies the Active Document of state changes.
    22 CMDID_REFRESH Asks the Active Document to refresh its display. Implemented by the Active Document.
    23 CMDID_STOP Asks the Active Document to stop its processing.
    24 CMDID_HIDETOOLBARS Asks the Active Document to hide its toolbars. Implemented by the Active Document.
    25 CMDID_SETPROGRESSMAX Sets the maximum value of the progress indicator.
    26 CMDID_SETPROGRESSPOS Sets the current value of the progress indicator.
    27 CMDID_PROGRESSTEXT Sets the text contained in the progress indicator.
    28 CMDID_SETTITLE Sets the title bar text.
    29 CMDID_DOWNLOADSTATE Sent by the host when its download state changes.
    30 CMDID_STOPDOWNLOAD Stops the download when executed.
    31 CMDID_ONTOOLBARACTIVATED One of the container's toolbars has received the focus.
    36 CMDID_ENABLE_INTERACTION Sent by the Active Document host to tell the Active Document to either pause or resume any multimedia (audio or animation) in the Active Document.

    Sets a true value (1) for eArgIn if a multimedia file running in a control in the Active Document should be resumed, or false value (0) if the multimedia file should be paused.

    Internet Explorer 4.0 uses this command to inform an Active Document when it is minimized or completely covered by another window so that the Active Document can pause playing of multimedia information.

    37 CMDID_ONUNLOAD Sent by the Active Document host before navigation to another site is initiated or the host is closed. Set eArgOut to False (.F.) to prevent an Active Document from being closed by its host. Set eArgOut to True (.T.) to allow an Active Document to be closed by its host.
  • nExecOption
    A parameter passed to the CommandTargetExec event that indicates the default action desired for the specified command.

    The following table lists the values for nExecOption and the actions that are performed.

    nExecOption FOXPRO.H Constant Action
    0 CMDEXECOPT_DODEFAULT Use the default behavior, whether prompting the user for input or not.
    1 CMDEXECOPT_PROMPTUSER Execute the command after obtaining user input.
    2 CMDEXECOPT_DONTPROMPTUSER Execute the command without prompting the user. For example, clicking the Print toolbar button causes a document to be immediately printed without user input
    3 CMDEXECOPT_SHOWHELP Show help for the corresponding command, but do not actually execute the command.
  • eArgIn
    A parameter passed from the Active Document host to the CommandTargetExec event. This parameter is typically the null value, with the notable exception of when nCommandID is 36. When nCommandID is 36, eArgIn contains a value. See the table in the nCommandID parameter description above for more information about the logical value passed to eArgIn.

  • eArgOut
    An output parameter returned from the CommandTargetExec event to Active Document host. This parameter is typically the null value, with the notable exception of when nCommandID is 37. When nCommandID is 37 (indicating the Active Document host is about to close or navigate to another site), you can set eArgOut to False (.F.) to prevent the Active Document from being closed by its host. Set eArgOut to True (.T.) to allow the Active Document to be closed by its host.

Remarks

The CommandTargetExec event allows an Active Document to perform custom actions based on commands sent to the Active Document by its host. These commands may be sent in response to the user choosing a menu or toolbar item or triggering an event in the Active Document host. The value returned from the CommandTargetExec event notifies the Active Document host if you handled the command. If you didn't handle the command, the Active Document host may perform its own default processing of the command.

The following table lists the appropriate values to return from the CommandTargetExec event.

Return Value FOXPRO.H Constant Command Action
0 CMD_OK Command handled okay by the Active Document.

Return this value when the Active Document has handled the command identified with nCommandID. For example, if the Open command on the File menu on the host is chosen, your Active Document can determine in its CommandTargetExec event that nCommandID is 1 and then execute its own Open file routine, perhaps using the Visual FoxPro GETFILE( ) function.

1 CMD_NOTSUPPORTED Command not supported by the Active Document.

Return this value when the command identified with nCommandID is not recognized as a command that can be handled by the Active Document.

2 CMD_DISABLED Command disabled for the Active Document.

Return this value when the command identified with nCommandID is currently disabled and cannot be executed by the Active Document.

3 CMD_NOHELP No help available for the command from the Active Document.

Return this value when the Active Document doesn't support help for the command identified with nCommandID.

4 CMD_CANCELED The user canceled the execution of command.

Return this value when the Active Document attempted to handle the command identified with nCommandID but the user canceled the operation.

If the CommandTargetExec event contains no user code, 2 (command not supported by the Active Document) is returned to the Active Document host. If the CommandTargetExec event contains user code but doesn't include a RETURN statement, 0 (command handled okay by the Active Document) is returned to the Active Document host.

Visual FoxPro utilizes the IOleCommandTarget interface for the CommandTargetExec and CommandTargetQuery events. Search for IOleCommandTarget in the MSDN library for additional information about how these events are implemented.

You can control display of the "About Microsoft Visual FoxPro Runtime" dialog box through CMDID_PROPERTIES in the nCommand parameter.

To display the dialog

Return CMD_NOTSUPPORTED (1) from the CommandTargetExec event.

To suppress the dialog

Return CMD_OK (0) from the CommandTargetExec event. If there is no code in the CommandTargetExec event, the default action is for Visual FoxPro to display the "About Microsoft Visual FoxPro Runtime" dialog box.

See Also

CommandTargetQuery Event | GETFILE( ) function

Applies To: ActiveDoc Object