Microsoft KB Archive/822332

= BUG: &quot;Invalid procedure call or argument&quot; error message when you add a member variable by using the Class View Wizard in Visual C++ .NET =

Article ID: 822332

Article Last Modified on 12/29/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition

-



SYMPTOMS
When you use the Add Member Variable Wizard in Visual C++ .NET to add a variable to a Dialog control, you may receive the following error messages:

Error: Invalid procedure call or argument

Visual C++ .NET 2003 Internet Explorer script error
An error has occurred in the script on this page. Line: 480 Char: 4 Error: Invalid procedure call or argument Code: 0 URL: file://C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\VCWizards\MemVariableWiz\HTML\1033\default.htm

Visual C++ .NET 2002 error
An error has occurred in the script on this page. Line: 480 Char: 4 Error: Invalid procedure call or argument Code: 0 URL: file://C:\Program Files\Microsoft Visual Studio .NET\Vc7\VCWizards\MemVariableWiz\HTML\1033\default.htm



CAUSE
This is a bug in the automation code for the DialogID property. Whenever any custom enum definitions appear before the AFX IDD enum in the header file, the Add Member Variable Wizard cannot find the dialog resource ID in the first enum definition in the Microsoft Foundation Class Library (MFC) CDialog class and an error message is displayed.



RESOLUTION
Move any custom enum definitions after the IDD enum so that the IDD enum appears first in the file if you search from the top down.

The following code example shows how to add the custom enum definition after the IDD enum definitions: enum { IDD = IDD_TESTDLG_DIALOG }; enum cust_enum{}; // Put the custom enum definition here.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
 Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Under Project Types click Visual C++ Projects, under Templates click MFC Application, and then name the application TestDlg . In the MFC Application Wizard, click Application Type, set the application type to Dialog Based, and then click Finish. On the View menu, click Class View.</li> In the Class View dialog box, expand CTestDlg.</li> Define the custom enum. To add the custom enum, double-click CTestDlgDlg.</li>  In TestDlgDlg.h, add the following custom enum definition: enum cust_enum{}; before the line enum { IDD = IDD_TESTDLG_DIALOG }; </li> Right-click CTestDlgDlg, point to Add, and then click Add Variable. You may receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

You may also notice the same problem when you add a variable for any class that derives from the CDialog class and for the class that has the custom enum definition before the IDD enum in the header file.

Keywords: kberrmsg kbbug kbide kbwizard kbdlg kbpending KB822332

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.