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. Throwing an event with a nested UDT

Throwing an event with a nested UDT

Scheduled Pinned Locked Moved COM
question
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.
  • G Offline
    G Offline
    GizzoF
    wrote on last edited by
    #1

    Hi! I'm trying to implement a event that fires an UDT which contains another UDT. I have some doubts and questions. Here is the idl code: //------------------------------------------------------------------------ typedef enum { S1_item1 = 0, // and more ... }enumSample1; //------------------------------------------------------------------------ typedef enum { s2_item1 = 100, // and more ... }enumSample2; //------------------------------------------------------------------------ typedef struct { BSTR m_string1; // and many more... all BSTRs enumSample1 m_enum1; enumSample2 m_enum2; }st_NestedUDT; //------------------------------------------------------------------------ typedef enum { s3_item1 = -1, //<-- Is this ok? s3_item2 = 0, // and more ... }enumSample_3; Q1: Is the s3_item1 ok? I read somewhere that enums are finally unsigned short. //------------------------------------------------------------------------ typedef struct { enumSample_3 m_eS; // And here is where I want tht st_NestedUDT. // st_NestedUDT m_stNested; // VARIANT m_vntNested; }st_MainStruct Q2: Should be the nested UDT member a VARIANT or just a st_NestedUDT member? //------------------------------------------------------------------------ And the event is like: [id(2), helpstring("method OnNewOrder")] HRESULT OnNewOrder(st_MainStruct stInfo); And finally, how should I encapsulate the stInfo in order to call Invoke? My first thought was: IRecordInfo * pRI; hr = GetRecordInfoFromGuids(LIBID_MyLibraryLib, 1, 0, 0, IID_st_Main_Struct, &pRI); if(FAILED(hr)) return hr; CComVariant avarParams[1]; avarParams[0].vt = VT_RECORD; avarParams[0].pvRecord = stInfo; avarParams[0].pRecInfo = pRI; CComVariant varResult; DISPPARAMS params = { avarParams, NULL, 1, 0 }; hr = pConnection->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL); Q3: Is that right? Thank you in advance Gizzo

    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