ActiveX

From LabVIEW Wiki
Jump to: navigation, search

LabVIEW from version 5.x allows the use of Active X. DDE was supported in version 4 onwards. Version 5.1 includes Active X events.

The resource "Understanding ActiveX and OLE " by David Chappell is useful as a starting point. It's written at a high level with little or no code. You do need to gain an understanding of COM by reading the first few chapters before jumping to ActiveX containers.

If you decide to go with ActiveX as opposed to OLE, then the VI usage is limited to the invoke node, property node, and to the G data node. Out of these, the property node is the work horse. Connecting the ActiveX refnum to the refnum input of the property (or invoke) node allows you to specify which property (or method) you want to manipulate. Depending on the property used, you may find that the output from the node is another refnum that serves as input to another property node which then exposes a set of lower level properties that you can use.

If you use OLE, things work in a similar manner, but instead of embedding a control in your program, you're (essentially) creating a script that uses a different application. The application is referenced by using the open automation node. Specify the application by using the Select ActiveX Class offered by the Open Automation VI. The automation open refnums must be closed when finished with them by using the Close Automation VI. As for refnums created by cascading to lower level properties, it is adviseable to close them, but it may not be necessary (unconfirmed).

As for help on specific controls, you will have to rely on the help provided with the controls. COM specifies an interfacing method; there's no (easy) way LabVIEW can know about the properties and methods provided by the controls.

The capabilities offered by including COM in LabVIEW add to the flexibility of the language but, like CINs (Code Interface Nodes), exposes the developer to a lot of the lower level programming issues that were eliminated by LabVIEW. There's been some interesting discussion on the Info-LabVIEW list server concerning brittleness of LabVIEW applications due to different versions of applications, particularly MSOffice. Also, be aware that LabVIEW ActiveX containers do not support events before Version 5.1. So, if you want to respond to a double click on the leaf of a TreeView control, you won't be able to use the double click or hit test methods unless you upgrade your version.