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. COM
  4. Define a enum type variable on the Interface (ATL project) ?

Define a enum type variable on the Interface (ATL project) ?

Scheduled Pinned Locked Moved COM
questionc++help
3 Posts 3 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.
  • I Offline
    I Offline
    iman_kh
    wrote on last edited by
    #1

    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

    S V 2 Replies Last reply
    0
    • I iman_kh

      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

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      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 word enum. 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

      1 Reply Last reply
      0
      • I iman_kh

        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

        V Offline
        V Offline
        Vi2
        wrote on last edited by
        #3

        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

        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