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