Solved

error when Calling SubReport in VC++ by using ComponentOne VSView 7.0

Posted on 2003-10-25
4
331 Views
Last Modified: 2012-06-27
hi experts..
i have a problem when compile my code the error in this function
 
CVSReport CField::GetSubreport()
{
 LPDISPATCH pDispatch;
 InvokeHelper(0x27, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL);
 return CVSReport(pDispatch);
}
 
the error is
//////////
: error C2440: 'type cast' : cannot convert from 'struct IDispatch *' to 'class CVSReport'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.
//////////
 
plz tell me how i can solve this problem ?!?
 
with regard
 
sanad
0
Comment
Question by:Sanad78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9619237
Assuiming error is in the line

return CVSReport(pDispatch);

(you don't write this, I just guess):
What do you want to return? CVSReport instance? In the case you can write:

return new CVSReport(...);

and client should release the instance after using. When you write CVSReport(pDispatch), you actually call CVSRrport construtor:

CVSReport::CVSReport(LPDISPATCH pDispatch)

Do you have such constructor in CVSReport class?
0
 

Author Comment

by:Sanad78
ID: 9622207
thanx Mr AlexFM ...
 
i know i am not write this code ... this code come from ComponentOne
when u add the ActiveX Control (VSReport, VSPrinter)
 
the code in the .h file for CVSReport is
///////////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_VSREPORT_H__6303DD5F_1F48_420C_8AFC_8A939A7CADE1__INCLUDED_)
#define AFX_VSREPORT_H__6303DD5F_1F48_420C_8AFC_8A939A7CADE1__INCLUDED_
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
 
// NOTE: Do not modify the contents of this file.  If this class is regenerated by
//  Microsoft Visual C++, your modifications will be overwritten.
 

// Dispatch interfaces referenced by this interface
class CLayout;
class CDataSource;
class CGroupCollection;
class CSectionCollection;
class CFieldCollection;
class COleFont;
 
// CVSReport wrapper class
 
class CVSReport : public CWnd
{
protected:
 DECLARE_DYNCREATE(CVSReport)
public:
 CLSID const& GetClsid()
 {
  static CLSID const clsid
   = { 0x3a6f7f8d, 0x45e5, 0x11d4, { 0xac, 0x3e, 0xad, 0xbc, 0xe8, 0xb3, 0x4, 0x10 } };
  return clsid;
 }
 virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL)
 {
  return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
 }
 
    BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL)
 {
  return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey);
 }
 
// Attributes
public:
// Operations
public:
 CString GetReportName();
 ....
};
 
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
#endif // !defined(AFX_VSREPORT_H__6303DD5F_1F48_420C_8AFC_8A939A7CADE1__INCLUDED_)
 
///////////////////////////////////////////////////////////////////////
 
i tired to write
////////////////////////////////////////////
CVSReport() {}  // Calls COleDispatchDriver default constructor
CVSReport(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
CVSReport(const CVSReport& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
////////////////////////////////////////////
but there is errors in the files where used that activeX controls
 
and thank u again sir
 
sanad
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10546140
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 10586129
PAQed, with points refunded (80)

ee_ai_construct
Community Support Moderator
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question