CommandTargetQuery, CommandTargetExec
These two events are the primary communication channels between an active document and its host (browser). CommandTargetQuery lets the active document tell the host what commands it's interested in. CommandTargetExec fires when the user does something in the host that the active doc might want to respond to.
Usage |
PROCEDURE acdActiveDoc.CommandTargetQuery LPARAMETERS aCommands, nCommandTextFlag, cCommandTextOut PROCEDURE acdActiveDoc.CommandTargetExec LPARAMETERS nCommandID, nExecOption, uArgIn, uArgOut |
Parameter |
Value |
Meaning |
aCommands |
Array |
A two-column array listing the commands (using a set of numeric values documented in the Help for CommandTargetExec) that the host thinks might happen soon. The active document can fill in the second column to indicate whether or not each command is permitted. |
nCommandTextFlag |
Numeric |
A numeric value indicating what extra information the host wants back from the active document. |
cCommandTextOut |
Character |
A parameter passed by reference to receive the extra information requested. |
nCommandID |
Numeric |
The command triggered by the user or host to which the active document can respond. The list of values is documented in Help. |
nExecOption |
Numeric |
A value (documented in Help) indicating the normal reaction to the specified command. |
uArgIn |
Numeric (perhaps other) |
An additional value passed with some commands to provide the active document with more information. |
uArgOut |
Expression |
A parameter passed by reference to let the active document return information to the host. |
Example |
* Running an active doc application in IE 4, * when IE's File menu is dropped open, * CommandTargetQuery receives a 6-row array. The * code here shows how you might respond to a couple * of those items. * This code goes in CommandTargetQuery FOR n = 1 TO ALEN(aCommands, 1) DO CASE CASE aCommands[n, 1] = 6 && Print aCommands[n, 2] = 2 && Enabled CASE aCommands[n, 1] = 4 && SaveAs aCommands[n, 2] = 2 && Enabled ENDCASE ENDFOR * Then suppose we want to subvert the behavior of those * two actions. Put this code in CommandTargetExec. * This.oForm is a custom property referencing a form in the app. * We don't recommend reacting to these menu choices * like this in real apps, but the Print action could, * for example, run a report. DO CASE CASE nCommandID = 6 && Print This.oForm.Caption = "Printed" CASE nCommandID = 4 && SaveAs CLEAR EVENTS ENDCASE |
See Also |