From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-21-2014 05:21 PM
I would like to change the callback function associated with a GUI button dynamically in the programming way.
Here is the code piece I tried, but it does not seem to work:
const char* pstrLabelSaveJpeg = "SaveJpegCb";
SetCtrlAttribute(pahel_id, ctrl_id ,ATTR_LABEL_TEXT, pstrLabelSaveJpeg);
int CVICALLBACK SaveJpegCb(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
Solved! Go to Solution.
08-21-2014 11:48 PM
The attribute you used is about the "label" of the button.
It is just an appearence attribute. You can write your own name on it, but that does not change the callback function.
You should change the ATTR_CALLBACK_FUNCTION_POINTER attribute, and you should not pass the function name as a string.
So your function call will look like this:
SetCtrlAttribute(pahel_id, ctrl_id, ATTR_CALLBACK_FUNCTION_POINTER, SaveJpegCb);
Of course, you have to declare the SaveJpegCb function somewhere above that line.
I think you have already done that.
08-22-2014 12:11 AM - edited 08-22-2014 12:12 AM
Your code does not work because the attribute you are trying to change is the text label of a control, not it's callback function...
You may want to have a look at the attribute ATTR_CALLBACK_FUNCTION_POINTER instead.
Oh, I see that Eren was faster
08-22-2014 09:08 AM
Hi, all:
I try your suggestions and it works here now.
Thanks!
Brad
08-22-2014 10:31 AM