Re: Throwing a event with a nested UDT
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Thu, 28 Apr 2005 12:16:02 -0700
Enum value can be negative of course.
Since you want Automation compatibility, you must use a
VARIANT in lieu of the nested struct, then put the nested
struct within that VARIANT.
The struct should be passed to the event by address, not
on the stack Otherwise the code seems fine.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Gustavo Fernández" <GustavoFernndez@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:6EC20BD2-2A7A-43C5-9DEE-8A93D1811412@xxxxxxxxxxxxxxxx
> 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 the 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 OnEventr(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 = pInfo;
> 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
> Gustavo
>
.
- References:
- Throwing a event with a nested UDT
- From: Gustavo Fernández
- Throwing a event with a nested UDT
- Prev by Date: Re: Outlook Express + Drag n Drop
- Next by Date: How do you find UDTs for an object
- Previous by thread: Throwing a event with a nested UDT
- Next by thread: hatch window
- Index(es):
Relevant Pages
|