Events event for ActiveX controls

Source: Internet
Author: User

http://labview360.com/article/info.asp?TID=10152&FID=165

Active X-Function library

for developers who use LabVIEW as a development environment, if they can call or reference objects developed by other programs such as OCX, DLL ... such as not only can shorten the development time, but also can design the necessary functions at will. After all, there are more or less limitations in LabVIEW's development environment, such as how to make a regular program with LabVIEW, that is, to put the program on the system tray. in order to solve this problem, LabVIEW provides an active X function library for Active X objects, using the elements in these libraries to refer to existing Active X objects.


Figure 1.1 The Active X-function library provided by LabVIEW

Not only on the block Diagram function library, but also on the front panel you can use the Active X container control metafile 1.2 to refer to ActiveX controls.


Figure 1.2 The active X container control element provided by LabVIEW

 

Property methods and events for Active x objects

before discussing how to use ActiveX, let's start with a simple description of the properties, methods, and events of the component. property refers to the appearance of the component, such as component size, appearance color, label name ... such as To change the properties of a component, you can specify it using the property Node Graph 1.3 In addition to the front panel changes in the design phase .


Figure 1.3 Property Node

method (Methods) to obtain an active function of the component, such as starting or removing the Datasocket action, the user can use the Invoke Node graph 1.4 to determine what function the component is to perform. This section will be explained in the final example of the production resident program .


Figure 1.4 Invoke Node

events, each object will have its own action, the most common is mouse down,value change ... such as in other words, it is the behavior that the component is now taking place. to get events to happen, you can take advantage of event structure to perform the incident trigger diagram 1.5. However, this is aimed at the


Figure 1.5 Events Structure

The UI (User Interface) component on the Front panel does not have access to events in this way for Active X and must be with the Register event Callback to get an ActiveX trigger event Figure 1.6


Figure 1.6 Register Event Callback

after understanding the property methods and events of ActiveX objects, let's briefly talk about the event. in the event I am here to divide it into two modes, with a description of the LabVIEW event mode is not the only two, in order to make it clear that the difference between the two events, so I only for these two ways to explain. One is UI-triggered event events, and the other is non-ui-triggered event events. UI-triggered event events, simply by using a mouse cursor or keyboard on a human-computer interface to change the parameters of a component on a human-computer interface, or Mouse down, Mouse up, or Key up ... And so on, when the state changes, the event events that are triggered, such event events, I call it ui-triggered event events. What does an event on a non-UI trigger to be an event trigger on a non-UI? For example, if I place 2 Boolean control elements on the UI one is the button (Trigger) and the other is the LED (Read Event). and the function I want is to change the parameters of the LEDs (true or FALSE) when the button is pressed. the value of the LED changes to trigger the events Structure, which is triggered by the led to call the dialog window. If you use the Figure 1.7 Way is not able to achieve the above required functions. because the Events structure can only be changed by the user on the front panel, for example, the user presses the button on the front panel or the keyboard to enter the numeric parameters ... And so on, to change the parameters in such a way that the event program in events structure can be implemented.










Figure 1.7 Failed to trigger the read Event

To achieve an Event trigger on a non-UI, you must use register event callback and callback VI to change the status of the Read event LEDs in 1.8, using the same method to trigger the value in the Read event. Change program.


Figure 1.8 Triggering the read event in the Register event callback mode

That is, at the beginning of the execution of the program, will register a callback Events, in callback VI, first obtained the Read event reference value (signaling) and value.


Figure 1.9 Callback Vi

When trigger value is changed, callback Vi is executed first, and then the parameter is passed to the read Event


Figure 1.10 Triggering the Read Event Value change program

reference Value (signaling) Figure 1.9. This change is then triggered by the event structure in the Read event (Value change) program diagram 1.10. You might ask, why mention non-ui-triggered event events? What's the relationship between using an ActiveX object and the Register Event callback? in the production of resident program chapters, in addition to the use of ActiveX component properties and methods, you must also get the mouse on the System icon trigger event, if there is no way to get a mouse trigger event, Then the function of the resident program cannot be completed.



 

 

Before you begin

in the section on one of the ActiveX objects, we have a little explanation for the ActiveX and Event section. Next, use the actual ActiveX component and the part of the previous chapter as a combination to design a resident program. the so-called resident program is in the lower right corner of the computer screen appears in the small diagram 2.1, when you move the cursor to an icon in that position and press the mouse button, the corresponding program will display the screen or perform other actions.


Figure 2.1 System Tray Icon

and we use STI control, the OCX element, to design a program like this one. Before starting this, you must copy the Sti.ocx diagram 2.2 and register it on your computer.


Figure 2.2 Sti.ocx

Once you have completed the above steps, you are ready to proceed with the creation of the resident program.

 

How to reference STI control components

the way to refer to ActiveX is to specify the STI control element directly on the front panel, in addition to using ActiveX objects on block diagram. Step One, in Control Panel 2.3, create an ActiveX container element and


Figure 2.3 ActiveX Container

Right-click on the ActiveX container and select Insert ActiveX object option 2.4.


Figure 2.4 Insert ActiveX Object option

Step Two, in the Select ActiveX Object window, select STI control element diagram 2.5. Of course, you can also use this method to refer to other OCX elements. Step Three, when finished, press the OK button. STI Control element diagram 2.6 appears on the front panel and block diagram .


Figure 2.5 Select ActiveX Object


Figure 2.6 STI Control element

 

Setting properties and Methods

in the previous discussion, you could use the property node and invoke node to specify the properties and methods of the component separately. Step One, in this example, specify the way in which the icon appears in the lower right corner, the position of the icon, and the text that appears on the icon.

Step two, after the completion of the property settings, at the beginning of the execution of the program, we use the appear mode of Invoke node, the diagram is placed on the system tray.

step three, at the end of the program, add an Invoke node remove at the end of the program, which removes the icon that appears on the system tray. Without this step, the diagram will not be removed when the program stops executing.

after completing the above steps, execute the program. View the icon that appears rocket on the system tray, pointing the cursor to?? ROCKET Icon, the prompt text for STI System tray test appears.

Of course, such a result is not complete, because it is not enough to put the icon on the system tray, and must match the mouse button action to get the event.

 

Using callback VI to get events

Step one, add a register event Callback Node to the block diagram and point the STi ActiveX object to the event.

Step two, select the Dbclick of STI as the trigger condition for the event.

step Three, add a Boolean Indicator named event. Create a Boolean reference and point to the user parameter contact.

step four, on the register Event Callback node's VI ref junction, press the right mouse button. in the

Select the Create Callback VI option on the menu to build Callback VI.

step Five, in the block diagram of Callback VI, generates the property Node,value and value (signaling) of the event, and is reversed with not. This is required to allow the Boolean to have an on and off parameter change.

Step Six, the next is to try the results of the program execution, when the mouse cursor on rocket icon Press double click, the event led will do on (OFF) changes. ROCKET icon disappears when you stop the program. Conclusion The discussion here is more basic usage, in the actual use you can also refer to different OCX



objects to design your program. the use of register Event Callback node is not only used on ActiveX objects, you can also use it to make Windows calls.

Events for ActiveX controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.