LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

eventData1 - CallCtrlCallback

Hi.

 

I want to send extra flag information when calling a CallCtrlCallback(,,,eventData1,eventData2,).

 

When pressing the buttons on the panel the debug window shows that these are not used (default value is 0).

Can eventData1 and eventData2 be freely used?

 

Thanks.

0 Kudos
Message 1 of 4
(4,179 Views)

EventData parameters should not be considered freely available to the programmer: they hold some useful values that you must be aware of so that you can use them when needed. As an example, EventData parameters show the mouse X/Y positions on all click events. In userint.h, where individual events are defined, you can find the value passed in EventData parameters on each event.

If you want to pass user defined values to a control or a panel callback yo can use CallbackData instead: this parameter is gauranteed to never be used by the IDE and is provided exactly as a way of passing user-defined data to a callback. When using CallCtrlCallback CallbackData is not part of the function prototye, so you may need to store the desired value on the control by means of SetCtrlAttribute (panel, control, ATTR_CALLBACK_DATA, (void *)myData); inside the callback you must cast the value passed to the appropriate data type before using it.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 4
(4,172 Views)

Hi Roberto.

 

Your information is what I needed to do.

 

Thanks.

 

 

One more question:

When using the panel to press the buttons (On/Off in this case) the callback automatically knows the state to put the button in and changes the color etc.

However, if I call the CallCtrlCallback() in my code it does not change the state (or color) of the button. Is this expected?

I can get around this by setting the value before calling CallCtrlCallback():

 

/* Turn on the SYS-RESET button */
SetCtrlVal (panelMain, PANEL_MAIN_SYSRESET,
1);
result
= CallCtrlCallback (panelMain, PANEL_MAIN_SYSRESET, EVENT_COMMIT, eventData1, eventData2, &returnValue);

 

Is this the prefered way to do it?

 

Thanks.

 

0 Kudos
Message 3 of 4
(4,169 Views)
Yes, this behaviour is expected: when calling CallCtrlCallback you are executing the code related to some event (EVENT_COMMIT in your case) but you are not actually acting on the button, so if you want to change its state you must set it previously with SetCtrlVal.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(4,157 Views)