12-06-2018 04:10 PM
How do I error check if my checkbox is checked or not? I have three of them, I just need to figure out how to error check them if all three never get checked... I tried to do an error check with a boolean function and it still errored out even if I checked one.
So, I just realized that it seems I have a bug or something because my program also doesn't hit my callback function for the checkboxes at all. It just passes right through them.
Any help would be nice. Thanks
Solved! Go to Solution.
12-06-2018 07:31 PM
If it is in hot mode, a checkbox responds to EVENT_COMMIT events; inside the callback you can simply call GetCtrlVal to get the status: value is 1 if checked, 0 otherwise.
12-06-2018 08:08 PM
Can you paste here the block of code which reads the checkbox state? You can send the whole callback if it is not too long.
12-07-2018 07:02 AM - edited 12-07-2018 07:07 AM
int CVICALLBACK check_sn (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK:
GetCtrlVal (panelHandle, PANEL_chk_sn, &IsChecked);
sn = IsChecked;
break;
}
return sn;
}
int CVICALLBACK check_operator(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (panelHandle, PANEL_chk_operator, &IsChecked);
operator = IsChecked;
break;
}
return operator;
}
int CVICALLBACK check_partid(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (panelHandle, PANEL_chk_partid, &IsChecked);
partid = IsChecked;
break;
}
return partid;
}
12-07-2018 07:16 AM
First, You shouldn't return checkbox state from the callback. Callback normally must return zero. Nonzero returns causes events to be "swallowed".
Second, change the EVENT_LEFT_CLICK to EVENT_VAL_CHANGED. Your callback is called before the state is changed, therefore you cannot get the new value.
12-07-2018 07:56 AM - edited 12-07-2018 07:57 AM
So, all of them to VAL_CHANGED? I was playing around with the click event to see if that was the issue or not.
12-07-2018 08:18 AM
If all three callbacks are belonging to checkboxes, yes, you can convert them to EVENT_VAL_CHANGED.
Make sure you return 0 also, from those callbacks.
After you call GetCtrlVal, the recent value of the checkbox should be in the variable.