LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Register Event Callback

So, I looked for information, examples... etc for this command and I'm not capable of making it run. I have an ActiveX that has an especific event that is "Clickposition" so it gives me the UTM coordinates from a map when I click in a point. That's easy to do with Visual basic because I only have to put the event and the parameters it gives out (X and Y), but I have problems in Labview because I don't understand how to do it. I take the "Register Event Callback" command so I can get the "Clickposition" event, and I click the "create callback VI" in "Vi ref", but I can't go farther because I don't know where are the X and Y variables. Well, they are iside the VI ref, but I can't take them out there, and when I run the app, X and Y remain at 0 all time. So, I would need some help please.

 

Thanks

0 Kudos
Message 1 of 24
(8,095 Views)
The information should be in the "Event Data" control. It may be a variant, though without actually seeing it, I can't be more definitive. Can you provide any more information about the specific ActiveX component that you're using? Can you upload your callback VI?
0 Kudos
Message 2 of 24
(8,084 Views)
The ActiveX are UTM coordinates where you can paste a map and put an object and if you connect variables from a GPS, you have a gps navigator that you can customize, so you can also get the coords of mouse clicking, but that's not with a property, that's an event so I don't know how to do it. I created a ref VI, thats the default VI but with 3 indicators that I made.
0 Kudos
Message 3 of 24
(8,071 Views)

Hey Carlos,

 

You'll want to make sure that you are wiring the correct reference to the correct event. We have two great examples that show how the callback function works. If you go to the NI Example Finder and search for "Register event callback," you will see two very good examples:

 

ActiveX Event Callback for Excel.vi

ActiveX Event Callback for IE.vi

 

 You will see that the ActiveX controls are populated with their respected objects (IE, Excel, etc) and then those references are wired to a reg event callback function. Once the reference is wired to the event input, you will see the list of all the events for that ActiveX control populate. Once you select the event that you want, you'll want to create the callback VI. (just right click the VI  ref and create one) But your callback VI looks fine.


You will now have a VI that has the event data inside of it, you will most likely need to unbundle this to get your desired results (coordinates)

 

I would make sure that your event is being registered, because if it never "happens" then you will never see a change in the callback VI.

Chris Van Horn
Applications Engineer
Message 4 of 24
(8,064 Views)

CarlosSp wrote:
 I created a ref VI, thats the default VI but with 3 indicators that I made.

I'm not sure I understand what you mean by this. Didn't the "Create Callback VI" create that VI with the appropriate cluster? What is the ActiveX component that you're actually using? Is this something that is commercial?

0 Kudos
Message 5 of 24
(8,059 Views)

For Chris:

 

I looked the examples of Excel, IE and some more I have but didn't catch them, because VI ref were very modified. 

I did all things you say, wired the event, select the one I need, and created that VI ref, so the problem is that I don't know hoy to get those variables and put them in my main application, but I cheked them in the VI ref and they remain at 0 as I said in my first post, so there's something wrong with it.

 

For smercurio:

 

I wanted to say that I created that VI by clicking the " create callback VI" and then unbundled the output data and wire them to an indicator. The ActiveX is from a Visual Basicairplane indicators. I used some of them without problems, but now that I'm using the "Moving Map", I'm not capable to manage events related with it.

 

I don't know if there's something missing in "User's Parameters"

 

I attach the image of a part of my app where there's the ActiveX I'm talking about

0 Kudos
Message 6 of 24
(8,038 Views)

OK, I think I understand what your problem is. The callback VI is fine. I think you're trying to see the values of X and Y with the callback VI open and you clicking on the ActiveX component. You won't because the callback VI is reentrant. If you just want to see the values while running for, say, debugging, you can temporarily make the callback VI non-reentrant.

 

However, if you want to pass the values of X and Y back to your program you need to pass in some references to your own indicators so that you can transfer the values of X and Y to these indicators. This is done using the "User Parameter" input of the Register Event Callback node. The shipping example "ActiveX Event Callback for IE" shows how this is done. That example registers 2 events. One of them is the title change event. For this event the reference for a front panel string indicator is wired to the "User Parameter" input for that event registration. This reference is for the large "Title" string indicator on the front panel. In the callback VI the event data is unbundled and the value is passed into the control reference's Value property, which gets displayed on the main panel.

Message 7 of 24
(8,030 Views)
Thanks smercurio, it was missing the "User Parameter" that had to wire a string reference that is where the coords shoud be displayed. Now the problem is that I have 2 variable to show and can't put the same event twice, and I don't know if I have to get it as an array or what. Whatever, I tried it with only one variable and worked but not fine. The coord. X was given correctly, but not all times I clicked the map, only sometimes, with aleatory intervals of time and I don't know why because I have no retards or similar... :S
0 Kudos
Message 8 of 24
(8,018 Views)
The "User Parameter" field can be anything you want. In your case I would pass in a reference to a front panel cluster of 2 elements (X and Y). This way, in your callback VI you can write to the cluster directly.
Message 9 of 24
(8,010 Views)

Thanks smercurio, but how do I put the cluster or the array there? I wire it in the callback VI but I have an error un the main application. I put an array or cluster as indicator and a referenc wired to "Users parameter" but I have the next error:

"This control has no elements so its type is undefined. Place the control you want inside it." What's wrong there?

0 Kudos
Message 10 of 24
(7,991 Views)