Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/250847

From BetaArchive Wiki

Article ID: 250847

Article Last Modified on 12/11/2003



APPLIES TO

  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++ 6.0 Standard Edition
  • Microsoft ActiveX Template Library 3.0



This article was previously published under Q250847

SYMPTOMS

The ATL Connection Point wizard generates a proxy class that implements a connection point for an out going interface. If an out going interface has an event that takes an argument of type VARIANT, then the wizard generates the wrong code in the out going call (Fire method) for that event. The Visual C++ compiler gives these two warnings when you call this fire method in your code

warning C4305: 'argument' : truncation from 'struct tagVARIANT *' to 'bool'

warning C4800: 'struct tagVARIANT *' : forcing value to bool 'true' or 'false' (performance warning)

CAUSE

Implementing the Connection Point wizard generates the wrong code in the Fire_ method for the event that takes VARIANT as parameter. For Event1, with VARIANT parameter Param1, it generates this code

pVars[0] = &Param1;

instead of this

pVars[0] = Param1;

in Fire_Event1 method of the proxy class.

RESOLUTION

To work around this problem manually remove the "&" before the Param1.

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new ATL DLL/EXE project.
  2. Insert a simple object with Connection Point support.
  3. Add a method named Event1 to source(event) interface that takes a VARIANT as parameter
  4. Compile the project.
  5. Right-click the ATL class and click Implement Connection Point to bring up the Connection Point wizard.
  6. Select the event interface and click OK.
  7. Create a test method on the ATL object's incoming interface with VARIANT as a parameter and call it "Fire_Event1".

    STDMETHODIMP CTestQ::Test(VARIANT var)
    {
        Fire_Event1(var);
        return S_OK;
    }
    
                            
  8. Compile your application to see the warnings C4305 and C4800.



Additional query words: event VARIANT C4305 C4800

Keywords: kbbug kbconnpts kbpending KB250847