Calling a LabWindows™/CVI™ Callback Function within Another Callback Function

Updated Oct 24, 2020

Environment

Software

  • LabWindows/CVI

When inside a callback function, can I call the code from another callback function? 

For example, if there were two different buttons on the UIR file, button1 and button2, that were related to two callbacks, callback1 and callback2,  how could I call the code from callback1 from a certain section of callback2, without the need to press button1?

Two methods exist in order to achieve this result.

Option 1 :
You can make a call to the callback1 function from within callback2, making sure to pass the event argument as an EVENT_COMMIT. 
Callback functions are standard C functions, so you can call them from other parts of your program. 
See Example.zip, attached to this document, for an example.

Option 2 : 
Another way to do it is by using the CallCtrlCallback function.
This function is interesting as, if the control does not have any callback function, no error will be thrown. The function will simply do nothing.
This will also allow you to call callback functions of dynamically created controls.

Attachments