In Clarion, I'm looking to set the definition for an OLE dynamically in a window. Right now, this is how I define two OLE objects in a window:
Window WINDOW('Test ActiveX Window'), AT(,,431,92), FONT('MS Sans Serif', 8,, FONT:regular), COLOR(COLOR:White), CENTER, ALRT(F2Key), TIMER(10), GRAY
OLE, AT(10,3,11,7), USE(?MyOLE1), HIDE, CREATE('MyActiveX.MyActiveXCtrl.1'), COMPATIBILITY(021H) END
OLE, AT(30,3,11,7), USE(?MyOLE2), HIDE, CREATE('SomeOtherActiveX.SomeOtherActiveXCtrl.1'), COMPATIBILITY(021H) END
END
Both objects contain the same method definitions (ex. TestMethod
), almost like they implement a common interface. I can currently call them conditionally like this:
if (condition)
testStr = ?MyOLE1{'TestMethod(param1)'}
else
testStr = ?MyOLE2{'TestMethod(param1)'}
end
What I'd like to do is only create one object, and then dynamically set the control's definition. I know there are other ways to simplify this (OCX wrappers, etc), but based on the project's requirements, this is how it has to be done. At some point, this code will grow from 2 objects to many more and this will be a lot cleaner.
How can I dynamically set the control's definition (the MyActiveX.MyActiveXCtrl.1
part)?
Here is how to create an OLE object dynamically:
Data
MyOLE Long
Code
MyOLE = 0
MyOLE = Create(0, CREATE:OLE)
! Set the OLE's control definition dynamically:
if (condition)
?MyOLE{PROP:Create} = 'ACTIVEXIDTECH.ActiveXIDTechCtrl.1'
else
?MyOLE{PROP:Create} = 'SomeOtherActiveX.SomeOtherActiveXCtrl.1'
end