09-18-2008 01:06 AM
I have a control that triggers timer this way:
case CONTROLSET_ESAUTOPWR:
PwrDmd_saved = 0;
GetCtrlVal(PanelControlset[i],CONTROLSET_ESAUTOPWR,&Es_auto_power[i]);
if (Es_auto_power[i])
{
SetCtrlAttribute (PanelMenus,MENU_ESAUTOPWR_TIMER,ATTR_ENABLED,TRUE);
}
else
{
SetCtrlAttribute (PanelMenus,MENU_ESAUTOPWR_TIMER,ATTR_ENABLED,FALSE);
}
break;
The timer has it's own callback function that runs every 2 sec.
When I enable the timer control the callback function runs.
But when I disable the timer control the callback function doesn't stop.
So to stop this function I must exit the program. It's prohibitive to exit the program such way.
What is wrong in my example? How can I stop the timer control callback execution?
09-18-2008 01:56 AM
I see no evident reason for this misbehaviour: are you sure the "else" case is actually executed? If I'm not wrong you have a callback associated to several controls with a switch on the control ID: in this structure care must be taken in panel handle and control id, to be sure that you are addressing the correct control both when retrieving its value in GetCtrlVal and when setting the timer enable attribute. Placing a breakpoint and checking all these values may help you in debugging this situation.