Define a enum type variable on the Interface (ATL project) ?
-
hi, i want to define an enum type variable on the Interface , so i have defined an enum within interface and then take a property from this enum, but have encountered with a compile time error !? what is my mistake and what is its solution? interface IXFSReceipt : IDispatch { enum RPtrResolution { RPTR_RESOLUTION_LOW, RPTR_RESOLUTION_MEDIUM, RPTR_RESOLUTION_HIGH, RPTR_RESOLUTION_VERYHIGH }; HRESULT Resolution([out, retval] RPtrResolution* pVal);<<<<<<<< ERROR1 HRESULT Resolution([in] RPtrResolution newVal); }; ERROR1 : error MIDL2025 : syntax error : expecting a type specification
-
hi, i want to define an enum type variable on the Interface , so i have defined an enum within interface and then take a property from this enum, but have encountered with a compile time error !? what is my mistake and what is its solution? interface IXFSReceipt : IDispatch { enum RPtrResolution { RPTR_RESOLUTION_LOW, RPTR_RESOLUTION_MEDIUM, RPTR_RESOLUTION_HIGH, RPTR_RESOLUTION_VERYHIGH }; HRESULT Resolution([out, retval] RPtrResolution* pVal);<<<<<<<< ERROR1 HRESULT Resolution([in] RPtrResolution newVal); }; ERROR1 : error MIDL2025 : syntax error : expecting a type specification
Don't be afraid to search through the
.IDL
files that come with the compiler or SDK. On my system I searched all the.IDL
files in "C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE" for the wordenum
. Here's the first example:typedef enum tagSCRIPTSTATE {
SCRIPTSTATE_UNINITIALIZED = 0,
SCRIPTSTATE_INITIALIZED = 5,
SCRIPTSTATE_STARTED = 1,
SCRIPTSTATE_CONNECTED = 2,
SCRIPTSTATE_DISCONNECTED = 3,
SCRIPTSTATE_CLOSED = 4,
} SCRIPTSTATE ;
/* ....Later.... */
[
object,
uuid(DB01A1E3-A42B-11cf-8F20-00805F2CD064),
pointer_default(unique)
]
interface IActiveScriptSite : IUnknown
{
HRESULT GetLCID(
[out] LCID *plcid
);
HRESULT GetItemInfo(
[in] LPCOLESTR pstrName,
[in] DWORD dwReturnMask,
[out] IUnknown **ppiunkItem,
[out] ITypeInfo **ppti
);
HRESULT GetDocVersionString(
[out] BSTR *pbstrVersion
);
HRESULT OnScriptTerminate(
[in] const VARIANT *pvarResult,
[in] const EXCEPINFO *pexcepinfo
);
HRESULT OnStateChange(
[in] SCRIPTSTATE ssScriptState
);
HRESULT OnScriptError(
[in] IActiveScriptError *pscripterror
);
HRESULT OnEnterScript(void);
HRESULT OnLeaveScript(void);
}Steve
-
hi, i want to define an enum type variable on the Interface , so i have defined an enum within interface and then take a property from this enum, but have encountered with a compile time error !? what is my mistake and what is its solution? interface IXFSReceipt : IDispatch { enum RPtrResolution { RPTR_RESOLUTION_LOW, RPTR_RESOLUTION_MEDIUM, RPTR_RESOLUTION_HIGH, RPTR_RESOLUTION_VERYHIGH }; HRESULT Resolution([out, retval] RPtrResolution* pVal);<<<<<<<< ERROR1 HRESULT Resolution([in] RPtrResolution newVal); }; ERROR1 : error MIDL2025 : syntax error : expecting a type specification
You should use the full name for enum, i.e. "enum RPtrResolution", because of C nature of MIDL compiler. For example,
HRESULT Resolution([out, retval] enum RPtrResolution* pVal);
HRESULT Resolution([in] enum RPtrResolution newVal);OR you should use a "typedef" statement, suggested by Stephen Hewitt.
typedef enum RPtrResolution
{
...
} RPtrResolution;With best wishes, Vita