Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Compile Errors with Measurement Studio ActiveX Controls in Visual C++

Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 8.0.1
Primary Software Fixed Version: 8.0.1
Secondary Software: Measurement Studio>>Visual Basic Support

Problem:
I'm trying to use one of the Measurement Studio ActiveX User Interface controls in Microsoft Visual C++ (MFC). When attaching a member variable to the control, a wizard generates some wrapper code and then creates the member variable. However, when I attempt to compile, I receive the following errors:

c:\CtrlDialog4\graph.h(748): error C2061: syntax error : identifier 'CWAnnotation'
c:\CtrlDialog4\graph.h(578): error C2061: syntax error : identifier 'CWPictureDisp'
c:\CtrlDialog4\graph.h(548): error C2061: syntax error : identifier 'CWPlot'
c:\CtrlDialog4\graph.h(512): error C2143: syntax error : missing ';' before '*'
c:\CtrlDialog4\graph.h(512): error C2501: 'CCwgraph1::CWPictureDisp' : missing storage-class or type specifiers


What happened and how do I correct this?

Solution:
The problem is that the member variable was added before the Measurement Studio Add/Remove Class Library wizard had a chance to put the information that associates the Measurement Studio-provided classes with the ActiveX controls into the project file. To fix the problem:

  1. Remove the files from your project that the Add Variable Wizard generated (graph.h and graph.cpp in the example case and cwgraph.h and cwgraph.cpp in the default case).


  2. Go to the header file of the dialog or view class to which you added the graph. Remove the #include for the generated header file (graph.h in the example case).


  3. Change the data type of the member variable (m_graph in the example case) to CNiGraph. Use the Measurement Studio-supplied data types instead of the automatically generated data types. These data types are documented in the Measurement Studio reference. Refer to Using the Measurement Studio Visual C++ User Interface Controls topic in the Measurement Studio Documentation for more information.
The process you went through causes Visual C++ to generate wrapper classes for the Measurement Studio ActiveX controls. Unfortunately, Visual C++.NET (MFC) does not generate the wrappers properly. This is explained inĀ KnowledgeBase 2IECTLXL. Visual C++ 6.0 generates complete wrappers, but they are complex and non-intuitive to use.

Measurement Studio includes a set of custom Visual C++ classes that provide interfaces to the Measurement Studio ActiveX controls. The names of these classes begin with CNi. For example, the graph class is CNiGraph and the axis class is CNiAxis. Besides being complete, these classes offer a variety of benefits over the automatically generated wrappers. These benefits include function overloading, support for calling the control from any thread, and automatic data type translation from COM data types, such as BSTR and SAFEARRAY to MFC data types and MFC-based Measurement Studio data types such as CString and CNiReal64Vector.

The Visual Studio Add Variable Wizard requires that information be added to the Visual C++ project file so that the wizard knows what Visual C++ class to use in the member variable declaration for the ActiveX control. If the Add Variable Wizard does not find this information in the C++ project file, it generates the wrappers and puts the information into the project file.

The Measurement Studio Add/Remove Class Libraries Wizard and the Measurement Studio new project wizards also add this information to the project file when you add a Measurement Studio class library that includes classes that provide interfaces to ActiveX controls. The Measurement Studio wizards, however, associate the Measurement Studio classes with the ActiveX controls. When you subsequently use the Visual Studio Add Variable Wizard, it sees the information that the Measurement Studio wizard put in the project file and then uses the Measurement Studio class instead of trying to generate a class.

Related Links:
KnowledgeBase 2IECTLXL: Why Are the Microsoft Visual C++ .NET-Generated Wrappers for Measurement Studio ActiveX Controls Incomplete?
KnowledgeBase 2MQCJIMQ: Adding Measurement Studio Controls to an MFC Project in Microsoft Visual C++
KnowledgeBase 0QECHJ1J: Loading Measurement Studio ActiveX Controls into Visual C++ 6.0

Attachments:





Report Date: 08/02/2004
Last Updated: 11/30/2006
Document ID: 3C1FIB5B

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit