Silmarba...
Ok, having seen it and run it, I think I can help you out here some more.
It is related to what I said previously, in that it is related to the way you are handling the various callbacks.
I have included the following two lines with each call back:
printf("*********************************\nChange Color CALLBACK\nEvent:%d\nControl:%d\nEventData1:%d\nEventData1:%d\n*********************************\n",event,control,eventData1,eventData2);
printf("*********************************\nAQUIRE CALLBACK\nEvent:%d\nControl:%d\nEventData1:%d\nEventData1:%d\n*********************************\n",event,control,eventData1,eventData2);
When you run your application, you can get even more weird behaviour than you state. For example, click the Aquire Button, and then click anywhere else (even off the window).
I shall try and explain it a bit more:
Lets say I run the application,and then I click the aquire button.
This causes the callback Acquire_MSMAM to be called.
You get the attribute for the control and do one of two things.
The first thing to note here, is that you are using the EVENT_COMMIT event.
A single click of your aquire button will cause the callback to be called more than once. In this first case it will be called 3 times.
1st Time: When it gets focus
2nd Time: Something happens
3rd Time: Something else happens (you'll have to check up on these because I forgot to write them down).
But the point is, more than one event will occur for a simple single click of your acquire button.
Now lets assume I have clicked the aquire button, and its quite happily running away, and I now click the Change Color button.
You should see that the Call Back for the Acquire Button is called first.
This is because this will generate an EVENT_COMMIT but the event will be a LOST_FOCUS. Since you clicked off the control and onto a new one, the old one has to lose focus and hence generates its own call back, before it performs the callback on the Change Color Callback.
In this case, it will switch off the Acquire button before it actions the change color callback.
Also, since you don't control how many times it performs the ON and OFF action for the acquire, it gets confused quite easily when you start clicking elsewhere.
You need to check your logic when starting and stopping the acquisition, and also when change color.
Define Some Rules:
1. Only Start and Acquisition if:
a. One is not already running
b. Or, If the control is showing 'off', an acq must be running so don't start another one.
c. If the control is showing 'on', then don't stop an acq.
etc etc
Don't just use EVENT_COMMIT, you must use EVENT_COMMIT and something else, since multiple events can occur on a control, and also events can be generated when pressing other controls. You will have to say use the Control_ID, the eventData1 and eventData2 to actually determine what exactly you want to do.
Just run your app with the new source file attached and look at the I/O Window, and see the events that occur. Single Stepping through the app with this is not the same as when you run it, because the action of clicking off the application when in single step mode, will of course generate its own different set of events.
So, just run it at full speed and watch the I/O Window.
If I get time, I will try and put the proper fixes in for you, but with the above information, you should now see what is happening...
Let me know
Chris
(Mail me at chris.a.wright@motorola.com) if you want a quicker reply offline from here)