LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

install control callback

I am trying to speed up a program by discarding unnecessary callbacks. Thats fine. However,I am struggling to use InstallCtrlCallback to recover them within the program. I do not know what to enter for the "eventFunction" or for the "callbackData". Can someone send me or direct me to a program example. Thanks.
0 Kudos
Message 1 of 2
(3,122 Views)
The event function is the function responsible for handling events generated by the control; it must be decleared before it can be used. If you put a callback function inside a control in the UIR editor and then generate the code associated with the UIR, two items will be generated: the function declaration in the header file associated with the UIR (which is by default included in the source file) and the skeleton of the function in the source file itself.
To create a callback function from scratch you must do the same (you can copy the declaration in the header file and put it in a separate .h file or in the .c file: don't put it in the header file associated with the UIR file, 'cause it is re-generated every time you save the UIR, and your additions
to it will be lost). The name of the function you have created must be passed in the 'eventFunction' parameter to the InstallCtrlCallback() function.

CallbackData is a user-defined parameter: CVI neither fills it nor uses it. This parameter is normally NULL in a control callback, unless you fill it with SetCtrlAttribute or InstallCtrlCallback. To use it, you must pass a value casted to a void pointer, and cast the value to the appropriate type before using it.
I attach a sample project (taken from the NI site some time ago) that shows one possible use of callbackData. Other uses will arise from your needs.

I hope I've been clear. Feel free to write to me in case you need some more hints: roberto.bozzolo@eltra.net

Roberto


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 2 of 2
(3,122 Views)