Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

707 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

13 Experts available now in Live!

Get 1:1 Help Now