views:

203

answers:

2

Hello Everyone,

I've created a COM object using ATL. I want to create a new object that can be returned from a method, and passed in as a parameter. I've created the coclass, but I can't figure out how to add a method that will accept it as a parameter.

The error I'm getting is MIDL2025: syntax error: expecting a type specification near "IgBrush". I'm using Visual Studio 2008.

When I added an enumeration, I recall playing around with the IDL quite a bit, and eventually got it to accept the enumeration as a parameter. No such luck with the coclass.

From the default generated code that the ATL wizard provides, what are the steps needed to get this to work? (ie. what do I move where and why?)

+1  A: 

It would help if you put the IDL that you are using.

To use a type in MIDL you have to declare it first.

interface IMyFactory:IDispatch
{
  ...
};

interface IMyObject:IDispatch
{
  HRESULT SetFactory([in] IMyFactory * state);
}

But I'd recommend that you pass those parameters like IUnknown* or IDispach* (if they are appropiate), then last resource will be to use VOID* as parameters.

Ismael
A: 

This article might help:

http://vcfaq.mvps.org/com/12.htm

Rob