LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Polymorphic ActiveX Methods

I'm trying to whip up a Labview VI to interface to some existing VB
ActiveX servers.

The problem is that my servers use a class factory approach. For
example: say I have three visual basic classes like this

' class base

public sub aMethod
....
end sub

' class derived

implements base

private base_aMethod
.... ' my implementation of aMethod
end sub

public MySpecialMethod
' method available only though a reference to class derived
end sub

' class factory

public function MakeInterface ( byval iType as integer ) as based

select case iType
case 0: set MakeInterface = new base
case 1: set MakeInterface = new Derived
' and so on
end select
end function

Now, in vb I might write:

dim f as new fac
tory
dim b1 as base
dim b2 as base
dim d as derived

set b1 = f.MakeInterface(0) ' returns an object of type Base
set b2 = f.MakeInterface(1) ' returns an object of type Derived
set d = f.MakeInterface(1) ' also returns an object of type Derived

b1.aMethod ' legal
b2.aMethod ' also legal (calls the implementation in derived)
d.aMethod ' illegal (aMethod only available through base interface
d.MySpecialMethod ' legal
b2.MySpecialMethod ' will probably work due to late binding.

The problem I have is using the above approach in Labview. I call
MakeInterface with no problems and the Automation refnum returned is
for an object of type Base.

But, given that I provide a parameter of 1 to MakeInterface, I can't
find a way to get at "derived.MySpecialMethod".

How can I cast a reference to base into a reference to derived? This is
especially important as I need to handle activex events which are
specific to the derived class!

Keith Derrick



Sent via D
eja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 1
(2,251 Views)