02-28-2006 06:57 PM
02-28-2006 08:55 PM
Hi Dave.
What you need to do is:
Cheers,
Colin.
02-28-2006 10:04 PM
Of course, thanks.
Tried it, but unfortunatly it's not working.
My actual code is this:
if ((panelHandlePassword = LoadPanel (panelHandle, "ATS.uir", PanelPass)) <0 ) return -1;
PasswordCtrl_ConvertFromString (panelHandlePassword, PanelPass_PasswordString);
InstallPopup(panelHandlePassword);
MessagePopup("","");
My code still continues on after I have called the password popup panel.
The password panel pops up fine, but so does the blank message box on the next line of code!
On a normal popup like PromptPopup() the code stops at that point and waits for a response, that's what I want.
Any idea what's going on?
Thanks
Dave 🙂
02-28-2006 11:32 PM
if ((panelHandlePassword = LoadPanel (panelHandle, "ATS.uir", PanelPass)) <0 ) return -1;PasswordCtrl_ConvertFromString (panelHandlePassword, PanelPass_PasswordString);
InstallPopup(panelHandlePassword);SetActiveCtrl(panelHandlePassword,PanelPass_PasswordString);RunUserInterface();
PasswordCtrl_GetAttribute(panelHandlePassword, PanelPass_PasswordString,ATTR_PASSWORD_VAL, s);
DiscardPanel(panelHandlePassword);
03-01-2006 12:04 AM - edited 03-01-2006 12:04 AM
David,
InstallPopup simply displays a panel and forces user action on that panel, it does not "freeze" program execution on it. Normally it is associated to a "Close" button or something like this whose callback discards the popup, as if you were looping inside a closed circle whose exit is that button. To obtain this behaviour your InstallPopup must be at the end of a callback that exits leaving the popup displayed so that RunUserInterface (called at program start) can manage events on that panel. There is absolutely no need of a second call to RunUserInterface which man make normal event processing confused.
In case of a password request, I personally hate to spread the code in multiple callbacks, so I do prefere using GetUserEvents () function inside a loop to manage user actions on the passowrd request panel. The skeleton of the application will be as follows:
Create your password request panel with a string control (Important: set its mode as "normal", NOT "hot!), a abort button and ok button (set as HOT).
Load the password request panel
InstallPopup
While (1) {
GetUserEvent (1, &pnl, &ctl);
if (pnl == PANEL_ABORT) {
// User has quitted: discard the panel
DiscardPanel ();
return 0; //Usually this code in inside a callback
}
else if (ctl == PANEL_OK) {
// Retrieve and test password value
If (password_ok) {
DiscardPanel ();
break;
}
}
}
Hope this helps
Roberto
Message Edited by Roberto Bozzolo on 03-01-2006 07:05 AM
03-01-2006 12:12 AM
03-01-2006 03:40 AM
03-01-2006 04:15 PM
Thanks guys.
Those solutions sound a bit cleaner than the 2nd instance of RunUserInterface(). Although for my application it appears to work just fine.
Does anyone know how the CVI popup routines like PromptPopup() actually do it?
Dave 🙂
03-01-2006 05:31 PM
I used Johns suggestion as it seems more elegant and it works a treat.
My final code is :
if ((panelHandlePassword = LoadPanel (panelHandle, "ATS.uir", PanelPass)) <0 ) return -1;PasswordCtrl_ConvertFromString (panelHandlePassword, PanelPass_PasswordString);
InstallPopup(panelHandlePassword);SetActiveCtrl(panelHandlePassword,PanelPass_PasswordString);while(GetActivePanel()==panelHandlePassword);
PasswordCtrl_GetAttribute(panelHandlePassword, PanelPass_PasswordString,ATTR_PASSWORD_VAL, s);
DiscardPanel(panelHandlePassword);
03-01-2006 05:31 PM
I used Johns suggestion as it seems more elegant and it works a treat.
My final code is :
if ((panelHandlePassword = LoadPanel (panelHandle, "ATS.uir", PanelPass)) <0 ) return -1;PasswordCtrl_ConvertFromString (panelHandlePassword, PanelPass_PasswordString);
InstallPopup(panelHandlePassword);SetActiveCtrl(panelHandlePassword,PanelPass_PasswordString);while(GetActivePanel()==panelHandlePassword);
PasswordCtrl_GetAttribute(panelHandlePassword, PanelPass_PasswordString,ATTR_PASSWORD_VAL, s);
DiscardPanel(panelHandlePassword);