08-04-2023 02:03 PM
I need to send a UI control event, through the message system so as to not be re-entrant, at the end of the control event callback to cause it to run as a loop.
I regularly call ProcessSystemEvents() so that the ui doesn't lock up. In MFC I could just call SendMessage() function with the control id and event id in the WParam. This would allow me to exit the callback function, and the next time the app message pump runs, it would fire the requested event. I've tried QueueUserEvent(), both with EVENT_COMMIT and with a generic message id 1001, but neither one fired the event callback. I've tried CallCtrlCallback(). This seems to call the callback function directly which causes it to be re-entrant.
Is there another way to do this?
Solved! Go to Solution.
08-04-2023 02:31 PM
I originally thought I couldn't use "PostDeferredCall(DeferredCallbackPtr deferredFunction, void *callbackData)" because the parameters didn't match the callback "int CVICALLBACK RunSequence(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)".
What I ended up doing is to create an intermediate function that I called using PostDeferredCall(), which in turn directly calls my callback with the proper parameters:
PostDeferredCall(&callRunEvent, NULL)
...
void callRunEvent(void *data)
{
RunSequence(hndMainPanel, PANEL_RUN, EVENT_COMMIT, data, 0, 0);
}
08-09-2023 01:38 AM
While your system works, I'm suspecting there may be a better, more efficient way of doing what you want than faking the user to compulsively click on a button. There are a couple ways of having a process running in the background leaving the UI responsive: if you can describe your process we may be able to suggest you some alternative.