Conditionally set OLE definition

眉间皱痕 提交于 2019-12-11 13:44:24

问题


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)?


回答1:


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


来源:https://stackoverflow.com/questions/24958491/conditionally-set-ole-definition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!