LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I programmtically add a callback to a button

I would like to be able to conditionally add a different callback to the same button. Is this possible and what statement should I use?
Thanks,
Donna
0 Kudos
Message 1 of 3
(3,302 Views)
You can use the InstallCtrlCallback function.

Luis
0 Kudos
Message 2 of 3
(3,298 Views)
As Luis said, you can use the InstallCtrlCallback to install an existing function as a callback for the selected control. The function installed as a callback should have the same prototype as callbacks generated by CVI. It should also return 0 unless you want to swallow the event.
If panelHandle is the handle to a panel with the constant name PANEL which has a control with the constant name CONTROL, and you want the callback to be MyCallback and you don't want to pass any callback data,

installErr = InstallCtrlCallback (panelHandle, PANEL_CONTROL, MyCallback, 0);
//....
int CVICALLBACK MyCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
case EVENT_COMMIT:
// your code goes here
break;
}
return 0;
}
0 Kudos
Message 3 of 3
(3,291 Views)