问题
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:
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.
来源:https://stackoverflow.com/questions/698273/atl-i-want-to-create-a-coclass-that-i-can-use-as-a-parameter-for-a-method-in-my