 HansiWWW
		
			HansiWWW
		
		
		
		
		
		
		
		
	
			07-24-2012 08:23 AM
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...
 
					
				
		
 RobertoBozzolo
		
			RobertoBozzolo
		
		
		
		
		
		
		
		
	
			07-24-2012 08:31 AM - edited 07-24-2012 08:33 AM
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;
}
 Wolfgang
		
			Wolfgang
		
		
		
		
		
		
		
		
	
			07-24-2012 08:32 AM
Sure, you can call a callback function as any other function.
You can also use the forum search, for this is a popular topic 
See e.g. here
 ebalci
		
			ebalci
		
		
		
		
		
		
		
		
	
			07-26-2012 10:41 AM
You can also use the ChainCtrlCallback function for more advanced functionality.
See the built-in CVI help for using that function.