ActiveX and LabVIEW
Print this age
This document introduces you to ActiveX and its various uses in LabVIEW.
Table of Contents:
Overview of ActiveX
ActiveX Automation with LabVIEW
LabVIEW as an ActiveX Container
ActiveX Events and LabVIEW
Information about OLE Variants and LabVIEW
Overview of ActiveX
ActiveX is the general name for a set of Microsoft Technologies that allows users to re-use code and link individual programs together to suit their computing needs. Based on COM (Component
Object Model) technologies, ActiveX is an extension of a previous technology called OLE (Object Linking and
Embedding).
The principle is that components need not be regenerated by each program, but rather, reused to fully give the
user the power to combine
applications together. LabVIEW 4.1 introduced support for ActiveX automation as a client. Expanding upon this,
LabVIEW 5.0
offered support for ActiveX automation as a server as well as support for ActiveX Containers, and with the release of
LabVIEW 5.1, ActiveX Events were supported as well.
ActiveX Automation
ActiveX/COM refers to the process of controlling one program from another via ActiveX. Much like networking,
one programacts as the client and the other as the server. LabVIEW supports automation both as the client and
the server. Both programs (client and server) exist independent of each other, but they are able to share information
between each other. This sharing ofinformation is achieved through communication of the automation client with
the ActiveX objects that the automation server exposes. The objects have properties and methods that can be accessed by the automation client. roperties are
simplyattributes of an object whose values can be set or retrieved from other programs. Similarly, methods are
functions that are performed on objects, and they can be invoked from other programs. An example of an ActiveX
property would be the program
name, height or width, and likewise, an example method could be the save or print method.
ActiveX Controls and Containers
The most common usage of ActiveX is via ActiveX controls, which are embeddable components that exist inside
ActiveX Containers. Any program that can function as an ActiveX container will allow users to “drop” ActiveX
controls into them.
From these containers, the ActiveX controls have their own functionality and properties. LabVIEW is an ActiveX
container
and can house ActiveX controls. Again, the embedded control is manipulated via properties and methods.
ActiveX Events
ActiveX is an event-driven technology. This means that programs report when certain events occur so that other programs or the user
can react
accordingly. With LabVIEW 5.1, National Instruments supported the processing of ActiveX events via both
automation and
embedding of ActiveX controls.
ActiveX Automation with LabVIEW
As mentioned earlier, LabVIEW supports ActiveX automation as both the client and the server. This means that
LabVIEW
can be used to interface with other programs from the LabVIEW programming interface. In this case, LabVIEW
acts as the
automation client and requests information of the automation server (the other program). Likewise, other ActiveX
automation
clients can interface with the LabVIEW ActiveX automation server. Common programs that are used to do this are
Microsoft Visual Basic and Microsoft Visual C++.
LabVIEW as an Automation Client
LabVIEW provides functions in its API that allow it to act as an automation client with any automation server.
The diagram
below shows the programming flow used in LabVIEW, and gives the associated functions with each block.
Figure 1.
In general, information about a program’s ActiveX automation server can be obtained from the program’s documentation or by browsing the program’s type library. Often, LabVIEW is used as an automation client for Microsoft Office programs, and their object
models are available online from Microsoft.
LabVIEW as an Automation Server
LabVIEW 5.0 and above supports the use of LabVIEW as an ActiveX server. This means that using ActiveX
automation other programs can interface with the LabVIEW automation server. Using an automation client,
it is possible to programmatically launch LabVIEW, open and run VIs, and pass their data back to the
calling program. This is done by interfacing with the LabVIEW type library which is located in the
"..\LabVIEW\resource" directory. By browsing this type library, information about the classes that
LabVIEW exports is available. In general, LabVIEW exports a creatable class, Application, and a
dispatch class, VirtualInstrument. For information on all the properties and methods exported by
the LabVIEW type library, please see the Online Reference in LabVIEW. Additionally, LabVIEW
executables can be enabled as ActiveX automation servers and can be accessed from any automation
clients including LabVIEW itself or even another LabVIEW executable.
See Also:
Using LabVIEW as an Automation Client with Microsoft owerPoint
Using LabVIEW as an Automation Client with Microsoft Excel
Using LabVIEW as an Automation Client with Microsoft Word
Calling LabVIEW as an Automation Server with Microsoft Visual C++
Calling LabVIEW as an Automation Server with a Microsoft Excel Macro
Calling LabVIEW as an Automation Server from Borland Delphi
Calling LabVIEW as an Automation Server with Visual Basic
LabVIEW as an ActiveX Container
LabVIEW introduced support for ActiveX controls by becoming an ActiveX container in LabVIEW 5.0.
In general, any ActiveX control can be embedded inside LabVIEW and then using that control’s properties and methods, LabVIEW can programmatically interact with the control. The flow chart
for using an ActiveX container is shown below:
Figure 2.
You can explore the properties and methods available to you using the property nodes and invoke nodes.
Simply wire the reference to the nodes and explore what properties and methods are available.
See Also:
Inserting ActiveX controls onto LabVIEW's Front Panel
Embedding Documents on LabVIEW's Front Panel
ActiveX Events and LabVIEW
LabVIEW support of ActiveX grew further with the release of LabVIEW 5.1. In this release, LabVIEW
introduced support for ActiveX events via automation and ActiveX controls embedded in containers.
ActiveX events allow programmers be notified of a specific occurrence and then act accordingly.
Commonly, programs wait until an event has fired and then after the event fires, continue with program
execution dependent on what event fired. The flow chart for setting up an ActiveX event sequence
in LabVIEW is shown below with the corresponding LabVIEW functions.
Figure 3.
See Also:
Using ActiveX Events with ActiveX Control in LabVIEW
Information about OLE Variants and LabVIEW
The Variant data type in ActiveX/OLE is used to pass data between programs. A variant can be anything;
it can represent any data type. It is necessary to use this data type when passing data between programs
because common data types in each program can be represented differently. For example, an array in LabVIEW
is represented differently than an array in Visual Basic. Thus, by passing data as variant we can pass that
information from one ActiveX component to another. The trick is to convert the variant data sent from one
program to a useable data type once it has been received in the other. In LabVIEW this is done using the To
G Data function. This function will allow you to convert a variant to a LabVIEW data type.
Create a subdirectory called "script" in the directory where the executable resides. If you are using the MATLAB script
node,
copy matscript.dll from LabVIEW\Resource\Script into this directory. If using the HiQ script node, copy hiqscript.dll in the
same fashion.
You can perform these steps as part of the application build. Add these DLLs as support files and specify a custom
destination for them using the "Custom Destinations" button under the "Source Files" tab.
If you do not perform this step, you will receive error 1053, failed to load script support dll.
C:\Documents and Settings\pp\My Documents\LabVIEW Data\script我把matscript.dll放在上面的路径中就可以了,在win98中可以,但是在2000/xp中还是不行,总是“未响应
这是两种软件开发工具对dll的调用规则 一般情况下默认的为C 规则,这种规则不需在函数前加关键字 而采用_stdcall规则即standard Windows calling 规则则必须在函数前加关键字_stdcall ,且必须在.def中进行函数声明! 上面说的是在编译dll时用到的 至于在调用时选用那种就要看你调用的dll中的函数属于那种类型了。
确切的说是函数调用时的参数传递方式.从最基础的角度看(比如汇编),调用函数的时候参 数是通过堆栈来传递的.参数先入栈,然后跳转到函数代码.函数一开始的地方就是参数出栈 . 这些工作编译器会替你做.不过,不同语言的编译器是按不同的顺序来操作的. 一种是参数从左到右入栈.很多语言都这样用.一般叫pascal方式.另外一种是C语言的方式 ,参数从右到左入栈.dll是编译好的二进制代码,所以调用的时候必须按dll编译时候取的规 则传递参数. 右到左的规则好像就C用.所以,windows规定的标准调用方式是pascal方式.所以用C写dll时 候往往建议用_stdcall 关键字来改变缺省的调用规则.不是必须的 如果是必须的话,调 用dll的时候反而没有麻烦了.呵呵.
这可能和你matlab安装程序有关,再安装matlab先确定你的电脑中已经安装了VC的compiler,matlab就是通过调用vc compiler来工作的。安装完后要选择vcc编译器或者matlab自带的lcc编译器(好像命令是:mcc -setup记不清了)。具体的操作到matlab板块问问。
用于实时处理,如果是同一程序反复执行,则只会在第一次调用时间长一点,不关闭程序,其他次执行时速度应该没问题。
但我编数据采集处理程序,因是迭代算法,用LABVIEW 编写太复杂了,而用MATLAB SCRIPE ,MATLAB程序则很方便,但要满足实时处理的需要,必须速度要快呀
请问LABVIEW中能否插入FLASH动画,如何加入?
可以将flash动画作为ActiveX文档插入LabVIEW程序的前面板,方法是:
(1)在前面板插入Controls>>ActiveX>>Container控件。
(2)在Container控件上单击鼠标右键,在弹出的菜单中选择Insert ActiveX Object。
(3)在对话框的上一栏中选择Create Control,在对话框的下面一栏中选择Shockwave Flash
Object,点击OK按钮将对象插入Container。
(4)在Container上单击鼠标右键,选择Property Browser,弹出属性对话框。
(5)在Movie一栏中填入flash文件(.swf)的路径,设定playing一栏为true。
图片附件: 1.jpg
怎么样在LV中打开pdf文件?能否做个例子? 在ActiveX 控件列表里面有 Adobe Acrobat Control for Active 这一项,但是我插入时电脑就死掉了,不知道什么原因.我想我的电脑的配置应该不成问题.我装的是Acrobat reader 6.0.能否帮我做个例子,谢谢!
我的调用过程非常简单:
1. 安装 Acrobat 6.0
2. 在 vi 中创建 ActiveX Container 控件,右击,选择 Insert ActiveX Object...,在弹出的列表中选择 Adobe Acrobat Control for Active。
3. 在框图中,给其属性 src 赋值为 pdf 文档路径。
但是这边有一个问题,如果运行时已经打开一个 pdf 文档,那么此时想要打开另外一个文档时出错(再次给 src 赋值时报错),然后我发现 LV 中可以调用的这个 ActiveX Object 的方法相比起在 Visual Studio 里面可以调用的方法少了很多(指一些必要的方法,不是 Visual Studio 控件继承的一系列方法),用 Visual Studio 可以实现再次加载 pdf 文档,而 LV 下不行。
用 National Instruments\LabVIEW 7.1\vi.lib\platform\browser.llb中的Open Acrobat Document.vi就可以了
我现在有一通信设备,提供的是OCX的ACTIVEX,如何在lv中注册,以便在builder后能正确应用
如果控件本身没有安装程序,你可以使用下面的命令:
regsvr32,看看他的帮助,了解一下,好象是用regsvr32 -i 控件名
是regsvr32 /s *.ocx
调用activex控键的属性节点,输入视频的URL,但是只能播放音频,没有视频。下载了一个NI的例子,发现存在同样的问题,百思不得其解,请问这是什么原因
有过类似的问题
Problem: I am using LabVIEW with a Windows Media layer 9.0 ActiveX container. When I play a movie file,
I can hear the sound and see the tracking bar show it's playing, but the video portion of it does not show up in
the Media layer display. What can I do to fix this black screen?
Solution: This is a known issue with the compatibility between Windows Media layer 9 and LabVIEW 6.1, 7.0,
and 7.1. Microsoft has changed the version of the Windows Media Software Development Kit used with
Windows Media Player 9. LabVIEW was designed to work with the SDK version used to build Windows
Media Player 8.0.
The issue can be resolved by downgrading your version on Windows Media Player to 8.0.
所以你选择低版本的media player就ok了,用6.4的吧
Yes, different midea player's rivision ,has different properties node.
try my simple sample attached, if you are interesting.
you can also try quicktime, it works with lv 7.1 .
i think i might have a vi that can play movies in media player 9 and 10, but i need to find it out where i store it.
flash调用
声音播放的问题
想把声音文件,如*.wmv等,在程序中播放出来,是不是要用到activeX?但有个控件 是windows Multimedia的 MCI控件,我的机子上好像没那个东西,在那里可以找到,或者有哪位大哥帮帮忙。
或者还有什么好的办法,多谢了,不胜感激!
我看过那些help中的例子了 帮助不很大
我想要的是程序运行立即连续不断播放声音 程序停了 那声音立即停
前面板又不要显示出来那个声音播放的框框什么的,多谢了
文章评论(0条评论)
登录后参与讨论