• Welcome to PlanetSquires Forums.
 

How to use UDT with containers like CSafeArray or CDicObj?

Started by Upsydaisy, May 21, 2023, 12:04:42 PM

Previous topic - Next topic

Upsydaisy

Hi,

I have been experimenting with the containers provided in Afx. I would like to store a UDT in something like a CSafeArray but cannot figure out the best way of doing it?

I get the feeling the best way of doing this is to dynamically allocate the UDT then store the address in the container?

I also notice that container types use CVar for the items, could this help?

Thanks

José Roca

You have to pass a variant of type VT_RECORD that will hold a pointer to a IRecordInfo object. The low-level IRecordInfo interface will be used to describe the members of the UDT and fill the values.

IRecordInfo interface: https://learn.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-irecordinfo

It's not easy, unless you have good low-level COM programming knowledge.