09-26-2002 06:18 PM
09-26-2002 11:43 PM
09-27-2002 10:28 AM
09-27-2002 05:14 PM
03-31-2015 01:31 PM
I have a similar problem. I have a control which does an InstallPopUp. This works fine using GetUserEvent. However when the child (the 1st popup) creates a grandchild (2nd popup) the GetUserEvent doesn't see the events until both pop-ups are extinguished. N.I. says that I shouldn't use a 2nd popup. I should use a display panel instead to avoid the problem. But I can't. Because Install pop-ups are modal, and I need the pop-up to be modal because I cannot let the user do anything else but act on the active pop-up panel.
I even created a very small project with all kinds of debug details to show N.I. how it works, (or not works as expected), but it seems they are not going to fix it because they insist I should not do a 2 level Instal Pop-up.
Has anyone had or seen this problem?
Thank you for answering.
04-01-2015 12:35 AM
It seems to me that previous answers on this thread should help you in solving your situation. Nevertheless, in the 13 years passed from the original posts I have changed a lot in my programming habits, and avoiding the use of GetUserEvents is one of the changes. I have found difficult in some conditions to discriminate "where" the event generated, which seems exactly your situation.
At present I handle all control events inside control callbacks leaving GetUserEvents to very few situations in which it's clear that only a few controls can fire events; in order to simplify the code, in case of small dialogs with a few controls and a few lines of code I use the same callback for all controls, discriminating which one fired it with a switch on on 'control' variable.
Is such an approach not feasible to you?
04-01-2015 07:03 AM
Thanks for getting back to me. This program is HUGE, 200,000 lines of code, so your suggestion would not apply to my case unfortunately. However we only have one instance where this problem ocurrs. Having a control create an InstallPopup, who in turns creates also an InstallPopup. We do this because we need to be modal in the popup and not let the user do anything else but answer the present popup, and extinguish it when done. I guess the only solution I see is to create my own global varaible which sets a flag when the corresponding popup is extinguished, and just have the while loop test for that condition, and forget the GetUserEvent function. But it is kludgy and for that reason it is not liked or accepted by my superiors.
04-01-2015 01:19 PM
Would you mind posting that little project you made for NI? 'cause I tried the code below and seems to me that it runs correctly, so you may be doing something different and I'd like to see it.
int CVICALLBACK TestPopup (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int pnl, ctl, tmp1H = 0, tmp2H = 0; if (event != EVENT_COMMIT) return 0; // Load a popup panel and handle buttons on it tmp1H = LoadPanel (0, UIR, MyPanel); InstallPopup (tmp1H); while (TRUE) { // Continue trapping events... GetUserEvent (1, &pnl, &ctl); switch (ctl) { case MyPanel_go: // Load the panel another time // and handle buttons on it tmp2H = LoadPanel (0, UIR, MyPanel); InstallPopup (tmp2H); while (TRUE) { // Continue trapping events... GetUserEvent (1, &pnl, &ctl); if (ctl == MyPanel_quit) { // Dismiss the panel DiscardPanel (tmp2H); break; } } break; case MyPanel_quit: // Dismiss the panel DiscardPanel (tmp1H); goto Out; } } Out: return 0; }
04-01-2015 02:14 PM
int CVICALLBACK CreateAchild (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int WhichPanel, WhichCtrl;
switch (event)
{
case EVENT_COMMIT:
InitValues(); // Mainly reset counters
if (StaticTest == 1)
{
SetCtrlVal(FatherUir,PANEL_Child_PanelId,Child); // static from .h
SetCtrlVal(FatherUir,PANEL_GrandChild_PanelId,Grandchild); // static from .h
}
else // dynamic
{
SetCtrlVal(FatherUir,PANEL_Child_PanelId,child); // dynamic from Load above
SetCtrlVal(FatherUir,PANEL_GrandChild_PanelId,grandchild); // dynamic from Load above
}
SetCtrlVal(FatherUir,PANEL_Child_ControlId,Child_ChildDone);
SetCtrlVal(FatherUir,PANEL_GrandChild_ControlId,Grandchild_GrandchildDone);
InstallPopup(child);
while (waitingForMyEvent) // wait for either Pop-up Done event
{
GetUserEvent (1, &WhichPanel, &WhichCtrl);
if (StaticTest == 1)
{
if ((WhichPanel == Child) && (WhichCtrl == Child_ChildDone)) // static from .h
{
BlinkAndBumpChild(); // blink once and bump counter
}
else if ((WhichPanel == Grandchild) && (WhichCtrl == Grandchild_GrandchildDone)) // static from .h
{
BlinkAndBumpGrandChild(); // blink once and bump counter
}
else if (ChildEventDone == 1) // this flag was set when control was clicked
{
BlinkChildTwice(); // this does NOT bump counter However it blinks TWICE
}
else if (GrandChildEventDone == 1) // this flag was set when control was clicked
{
BlinkGrandChildTwice(); // this does NOT bump counter However it blinks TWICE
}
else
{
BlinkNothing(); // theoretically we should never get here but we do
}
}
else // dynamic
{
if ((WhichPanel == child) && (WhichCtrl == Child_ChildDone)) // dynamic from Load above
{
BlinkAndBumpChild(); // blink once and bump counter
}
else if ((WhichPanel == grandchild) && (WhichCtrl == Grandchild_GrandchildDone)) // dynamic from Load above
{
BlinkAndBumpGrandChild(); // blink once and bump counter
}
else if (ChildEventDone == 1) // this flag was set when control was clicked
{
BlinkChildTwice(); // this does NOT bump counter However it blinks TWICE
}
else if (GrandChildEventDone == 1) // this flag was set when control was clicked
{
BlinkGrandChildTwice(); // this does NOT bump counter However it blinks TWICE
}
else
{
BlinkNothing(); // theoretically we should never get here but we do
}
}
}
break;
case EVENT_RIGHT_CLICK:
MessagePopup("When creating a child (pop-up) observe the 3 check boxes below","Each time a box turns black then white an event ocurred.\nSome events create multiple user events.\nThese check boxes are there to understand how the system works.");
break;
}
return 0;
}
04-01-2015 02:18 PM
attached is the entire project