Microsoft KB Archive/221700

= FIX: CommandTargetExec Ignores Return Value =

Article ID: 221700

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q221700



SYMPTOMS
In the ActiveDoc class of an ActiveDocument, the CommandTargetExec event ignores the value returned by the user in the RETURN command and returns CMD_OK under all circumstances. This means that the ActiveDocument host (normally Internet Explorer) assumes that the ActiveDocument handled any command called from the menu that was passed to the ActiveDocument.

In addition, the return values defined in FoxPro.h are incorrect.



RESOLUTION
While the FoxPro.h values can be corrected, they are still not handled correctly in Visual FoxPro 6.0 Build 8167 (original release). You need to upgrade to Visual Studio 6.0 Service Pack 3 for this functionality to work.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3.

For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



Steps to Reproduce Behavior
 Create a new Project, (aDoc.pjx). Create a new ADoc class (aDocTest in aDocClass.vcx) in aDoc.pjx.  Select FoxPro.h in the Class:Include File dialog box, and create the following procedures: PROCEDURE CommandTargetExec LPARAMETERS nCommandID, nExecOption, eArgIn, eArgOut

*!* The DO CASE is overkill in this sample, but it    *!* allows for handling different nCommandIDs. DO CASE CASE nCommandID = CMDID_PROPERTIES RETURN CMD_NOTSUPPORTED ENDCASE ENDPROC

PROCEDURE Run LPARAMETERS cHyperLinkTarget

DO FORM frmHiThere

READ EVENTS ENDPROC   Create a new Form (frmHiThere.scx) and drop a label on it. Set the properties as below and add the QueryUnload procedure: DEFINE CLASS frmhithere AS form

DoCreate = .T.   Caption = "Hi there!" Name = "frmHiThere"

ADD OBJECT lblhithere AS label WITH ; Caption = "Hi, neighbor, have a 'Gansett!", ; Height = 17, ; Left = 96, ; Top = 96, ; Width = 162, ; Name = "lblHiThere"

PROCEDURE QueryUnload *!* QueryUnload fires when the Close (x) button in        *!* the upper right corner is clicked.

CLEAR EVENTS ENDPROC ENDDEFINE  Build aDoc.pjx as an application (.APP). Open Internet Explorer. Go to the File:Open menu item, and choose aDoc.app. Once it opens in the browser, choose File:Properties.</li></ol>

If the application was built with Visual FoxPro 6.0 Build 8167, nothing happens because the ActiveDoc is improperly returning the "I handled it" value (CMD_OK). When the application is built with Visual FoxPro 6.0 in Visual Studio 6.0 Service Pack 3, the About Visual FoxPro 6.0 Run-time dialog box appears.

The FoxPro.h file is found in the Visual FoxPro home directory (=HOME(1)).

The return values for CommandTargetExec are defined improperly.

The lines reading: *-- CommandTargetExec Return Values should be: *-- CommandTargetExec Return Values
 * 1) DEFINE CMD_NOTSUPPORTED            2  && Command is not supported by the Active Document
 * 2) DEFINE CMD_DISABLED                3  && Command is disabled for the Active Document
 * 3) DEFINE CMD_NOHELP                  4  && No help is available for the command from the Active Document
 * 4) DEFINE CMD_CANCELED                5  && The user canceled the execution of the command
 * 1) DEFINE CMD_NOTSUPPORTED            1  && Command is not supported by the Active Document
 * 2) DEFINE CMD_DISABLED                2  && Command is disabled for the Active Document
 * 3) DEFINE CMD_NOHELP                  3  && No help is available for the command from the Active Document
 * 4) DEFINE CMD_CANCELED                4  && The user canceled the execution of the command

<div class="references_section">