Board index » delphi » Storing objects in Variant / ole variant

Storing objects in Variant / ole variant

How can store a object (Tcontrol, etc) in a variant field of an automation
object

Thanx
Rodrigo Ruiz
r_rui...@hotmail.com

 

Re:Storing objects in Variant / ole variant


Hi,

I do not think you can do that. Variants passed as parameters or results for
automation are limited to the types accepted by OleVariants - Delphi objects
are not going to be in the set of allowed types.

Ron.

Quote
nop wrote in message <01bd51f0$b6ce0d80$525154ce@nope>...
>How can store a object (Tcontrol, etc) in a variant field of an automation
>object

>Thanx
>Rodrigo Ruiz
>r_rui...@hotmail.com

Re:Storing objects in Variant / ole variant


Not something you should do, but I have a hack: Pointers are not allowed in
OLE variants, but there's nothing stopping you from casting a pointer to an
integer, which you can store in a variant. You can use classes where you can
use pointers (such as with TList), therefore:

var
  V: OleVariant
...
  V := Integer(MyClassInstance)
...
  TMyClass(Integer(V)).MyMethod

I'd never do this myself, though!

Hans-Christian

nop skrev i meldingen <01bd51f0$b6ce0d80$525154ce@nope>...

Quote
>How can store a object (Tcontrol, etc) in a variant field of an automation
>object

>Thanx
>Rodrigo Ruiz
>r_rui...@hotmail.com

Other Threads