Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Paul Squires on November 05, 2009, 11:41:26 PM

Title: Interface data types in TYPES
Post by: Paul Squires on November 05, 2009, 11:41:26 PM
Hi Everyone,

Am I correct in assuming that a reference to an Interface can be a data member of TYPE definition? I don't think so.

Something like:

TYPE MyType
   iMyClass As MyInterface
END TYPE

MyInterface would be defined in an earlier Class definition.

If it is not supported then would a good alternative be to define it as a DWord (iMyClass As DWord) and then somehow (Poke?) do the assignment to a locally declared variable for the MyInterface and handle the .AddRef stuff?


Title: Re: Interface data types in TYPES
Post by: José Roca on November 06, 2009, 01:47:21 AM
 
It is not currently supported.

Using a DWORD is the only possible workaround, but you have to manage the reference count by yourself, calling IUnknown::AddRef to make sure that the reference will be valid, converting it to an object variable to be able to use it and calling IUnknown::Release before the variable DIMed as your structure goes out of scope.
Title: Re: Interface data types in TYPES
Post by: Paul Squires on November 06, 2009, 03:09:35 AM
That's what I figured. Thanks.

I thought that we had discussed this before but I couldn't find it in my notes or the forum so I thought that I'd better ask just to be safe.