LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do to code the equivalent of: Wait ... until(click one button)?

Thanks to answer me and to send me a little code which explains the solution.
A French guy.
0 Kudos
Message 1 of 3
(3,110 Views)
This question doesn't really make sense in the CVI programming model. CVI follows an event driven programming model. The program is run by processing
events from UI, timers, etc. one at a time from an event queue. The event
processing loop is started by running RunUserInterface() and stopped by running
QuitUserInterface(). The event loop takes each event off the queue and processes
it by running the appropriate callback function for the event. When the
callback function is finished, the next event is taken from the queue and
processed. This model means you should never have to implement a "wait" for the next button pressed. It is built in. Look at some of the examples in the cvi\samples\userint directory or go through the CVI Getting Started to see exampl
es.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
Message 2 of 3
(3,110 Views)
If you have to display a panel and wait for the user to click one button to proceed, you could use GetUserEvent ().
I use it when I have to disply a popup panel
different from MessagePopup or PrompPopup or similar and I don't want to deal with a separate callback to manage controls on that panel. Here you find an example: I display a popup for the user to input a password (using the password control in toolbox to display an input string with the usual '*****' pattern while typing).

pwH = LoadPanel (0, UIR, pwd);
InstallPopup (pwH);
PasswordCtrl_ConvertFromString (pwH, pwd_pw);
errChk (PasswordCtrl_SetAttribute (pwH, pwd_pw, ATTR_PASSWORD_MAX_LENGTH, 12);
while (TRUE) {
GetUserEvent (1, &pnl, &ctrl); // Program waits until a button pressed

// Here when a button
have been pressed
if (ctrl == pwd_quit) { // 'Abort'
button
// Exit from function, close popup...
}
PasswordCtrl_GetAttribute (pnl, pwd_pw, ATTR_PASSWORD_VAL, pw); // Read password
if (strcmp (pw, correct_password))
MessagePopup ("PASSWORD",
"Incorrect password. Retry.");
else
break; // Correct password
}
RemovePopup (0);

I use it where I don't want to exit from the actual function to manage the 'Ok' button from the popup panel elsewhere.
Hope this helps


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 3
(3,110 Views)