Click here to Skip to main content
15,903,732 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: PWSTR length Pin
ThatsAlok17-Feb-05 4:50
ThatsAlok17-Feb-05 4:50 
GeneralRe: PWSTR length Pin
dabayi17-Feb-05 5:22
dabayi17-Feb-05 5:22 
Generalcalling member functions from a map Pin
Malcolm Smart16-Feb-05 21:43
Malcolm Smart16-Feb-05 21:43 
GeneralRe: calling member functions from a map Pin
Stuart Dootson17-Feb-05 10:33
professionalStuart Dootson17-Feb-05 10:33 
GeneralRe: calling member functions from a map Pin
Malcolm Smart17-Feb-05 21:46
Malcolm Smart17-Feb-05 21:46 
GeneralRe: calling member functions from a map Pin
Stuart Dootson18-Feb-05 4:39
professionalStuart Dootson18-Feb-05 4:39 
GeneralRe: calling member functions from a map Pin
Malcolm Smart18-Feb-05 5:36
Malcolm Smart18-Feb-05 5:36 
GeneralProblem with regular C Class in ATL Pin
rwestgraham16-Feb-05 0:06
rwestgraham16-Feb-05 0:06 
Sorry if this seems like a dumb question but ...

In the past I've built ATL components using only regular COM CoClasses.

Now I am working on a wrapper component to allow some legacy C++ code to be called via COM.

I've created just the basic standard ATL DLL framework with a single method that delegates the actual implementation to some legacy C++ code that I have. I pass in two strings which are source and target file paths. Then the legacy code is to be called to perform the actual work.

But I cannot call a method on the standard C++ class because even though I create a class instance, the compiler throws a C2228 error during a method call.

My ATL code looks something like:

**********************************************************************************************

STDMETHODIMP CMyWrapper::ExecuteLegacyParse(BSTR bstrSource, BSTR bstrTarget)
{

//Convert the input BSTRs to ANSI C Strings because ANSI Win32 API calls are required
USES_CONVERSION;
char* lpszSource = OLE2A(bstrSource);
char* lpszTarget = OLE2A(bstrTarget);

//So far, so good!


//Create an instance of CLegacyParse class
//No error occurs when creating the legacy CLegacyParse class which is a standard
//C++ class
CLegacyParse LegacyParse();

//So far, so good!

//The following line will not compile! I get a C2228 error - object on the left
//side of the operand must be a class/struct blah blah blah ...

int nResult = LegacyParse.ParseDocument(lpszSource, lpszTarget);

return S_OK;
}

**********************************************************************************************


So my question is, why am I able to create an instance of my CLegacyParse class (again, this is just a generic C++ class, not a CoClass), but I am not able to call a method because the compiler does not recognize my class instance reference, even though it allows the prerequisite instantiation of the C++ legacy class with no errors or warnings???

Is this a problem of COM _stdcall not being compatible with ordinary _cdecl call or something else?

Also, if I just cut and paste my legacy C++ methods into the wrapper COM CoClass as non-com private methods, and supply the function prototypes in the header, the component works fine.

But I don't want to do this because it obfuscates the fact that I simply want to create a COM callable wrapper around existing legacy C++ classes.

PLus I also want to understand exactly why it does not work calling the methods in a generic C++ class as opposed to calling them as private methods within the CoClass.

TIA

Robert
Questionhow to provide same con. point in different objects Pin
grinder15-Feb-05 23:00
grinder15-Feb-05 23:00 
GeneralList Control in ATL dialog Pin
abel66615-Feb-05 8:10
abel66615-Feb-05 8:10 
GeneralRe: List Control in ATL dialog Pin
Michael Dunn15-Feb-05 8:49
sitebuilderMichael Dunn15-Feb-05 8:49 
GeneralRe: List Control in ATL dialog Pin
abel66615-Feb-05 21:16
abel66615-Feb-05 21:16 
Questionhow to debug exchange store event sink Pin
muh22m15-Feb-05 7:53
muh22m15-Feb-05 7:53 
QuestionHow to get random numbers? Pin
Anonymous14-Feb-05 20:05
Anonymous14-Feb-05 20:05 
Generalspirit and unicode Pin
bruce2g14-Feb-05 14:40
bruce2g14-Feb-05 14:40 
GeneralRe: spirit and unicode Pin
Stuart Dootson15-Feb-05 5:19
professionalStuart Dootson15-Feb-05 5:19 
GeneralATL Collection Problem Pin
ekling14-Feb-05 11:32
ekling14-Feb-05 11:32 
Generalconvert PWSTR to LPCTSTR Pin
dabayi14-Feb-05 0:03
dabayi14-Feb-05 0:03 
GeneralRe: convert PWSTR to LPCTSTR Pin
rocky_pulley14-Feb-05 2:22
rocky_pulley14-Feb-05 2:22 
GeneralRe: convert PWSTR to LPCTSTR Pin
dabayi14-Feb-05 3:17
dabayi14-Feb-05 3:17 
GeneralRe: convert PWSTR to LPCTSTR Pin
Michael Dunn14-Feb-05 3:20
sitebuilderMichael Dunn14-Feb-05 3:20 
GeneralCommandBarControl.OnAction don't want to work Pin
JabraJabra12-Feb-05 22:01
JabraJabra12-Feb-05 22:01 
GeneralRe: CommandBarControl.OnAction don't want to work Pin
Jörgen Sigvardsson13-Feb-05 5:43
Jörgen Sigvardsson13-Feb-05 5:43 
GeneralRe: CommandBarControl.OnAction don't want to work Pin
JabraJabra13-Feb-05 6:14
JabraJabra13-Feb-05 6:14 
GeneralTrouble w/ Header Files Pin
SwimmerDave12-Feb-05 8:33
SwimmerDave12-Feb-05 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.