Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Problem with regular C Class in ATL

Problem with regular C Class in ATL

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helpquestioncom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rwestgraham
    wrote on last edited by
    #1

    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 wor

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups