LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Run Button Callback via other Button Callback

Hi,

 

I'm wondering if it is possible to launch a difined command button callback by activating another button callback.

 

E.g.

If I press Button A the callback of Button B is started...

0 Kudos
Message 1 of 4
(3,059 Views)

Of course it's possible: you can do it simply by calling the callback or by using CallCtrlCallback () function from the Programmer's Toolbox.

If you want to directly call the callback, you must pass the appripriate parameters to the function. Remember that while in a control callback, 'panel' parameter holds the panel handle the control is on, so if the second control is on the same panel you can simply pass this variable to the function; the same happens for 'event' variable: since a button responds mainly to EVENT_COMMIT event, you can simply pass that variable to the called callback.

 

int CVICALLBACK FirstControlCallback  (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{

    if (event != EVENT_COMMIT) return 0;

    your code here...

    // Call another control callback
    SecondControlCallback (panel, PANEL_BUTTON2, event, NULL, 0, 0);

    ... your code here

    return 0;
}

int CVICALLBACK SecondControlCallback  (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{

    if (event != EVENT_COMMIT) return 0;

    MessagePopup "Message", "This is the second button callback.");

    return 0;
}

 

 



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 4
(3,057 Views)

Sure, you can call a callback function as any other function.

 

You can also use the forum search, for this is a popular topic Smiley Wink

 

See e.g. here

0 Kudos
Message 3 of 4
(3,056 Views)

You can also use the ChainCtrlCallback function for more advanced functionality.

See the built-in CVI help for using that function.

S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 4
(3,035 Views)