Solved

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

Posted on 2003-10-25
4
326 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now