LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Select default button using "ConfirmPopup"

How does one select the default button with the ConfirmPopup call? It appears the default is "YES", which is a problem for our users. It is too easy to double dribble on the return key. What is a good way to prevent this or set the "NO" button as default?
0 Kudos
Message 1 of 4
(3,869 Views)
Two possibilities without need to struggle with system attributes, APIs and so.

The simplest: reverse your question! 😉
The user wants to exit but hasn't saved his work? Instead of asking him "Confirm exit? (You'll lose your work) Yes / No" simply ask "You have not saved your work: do you want to go back and save it? Yes / No"

A little less simple but still very easy: use GenericMessagePopup instead of ConfirmPopup.
GenericMessagePopup is a little more configurable in that it has three buttons and it's you that decide the text on the buttons and which of them to set as default.
In the example above: "Yo have not saved your work: do you REALLY want to exit? Yes, don't bother / No, drive me back to revise it / Save and exit" with the second (or maybe third) highlighted and set as default.


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?
Message 2 of 4
(3,862 Views)
Can you offer a code snippit that thoroughly illustrates its use?

Also, what are the VAL_GENERIC_whatever definitions for the various buttons and keys?
0 Kudos
Message 3 of 4
(3,851 Views)
I am posting here a sample of GenericMessagePopup: consider you are testing some device and tests fail. You can offer the user the possibility to repeat the test or accept test results with a message like this:

char msg[512];

strcpy (msg, "This device does not fulfils specifications.\n\n");
strcat (msg, "You can either:\n");
strcat (msg, "- Repeat the test to see if it matches\n");
strcat (msg, "- Accept this result\n\n");
strcat (msg, "What is your choice?");
if (GenericMessagePopup ("Automatic testing", msg, "Repeat the test",
"Accept this result", 0, 0, 0, 1, VAL_GENERIC_POPUP_BTN2,
VAL_GENERIC_POPUP_BTN2, VAL_GENERIC_POPUP_NO_CTRL) == VAL_GENERIC_POPUP_BTN1)
goto RepeatTest;
else {
// If you're here you want to accept test results
}

This code prompts the user with a chiuce and shows in the buttons a clear message instead of a generic Yes / No label. The active button is the second (Accept results), by pressing the Enter key the operator accepts this choice and there is neither a button associated to the Esc key nor an inout field for the operator to write something.

The VAL_GENERIC_xxx constants define the buttons pressed. The GenericMessagePopup permits you to define which is the default button (selected when the message is displayed), which button to associate to the Esc key (if any) and which to Enter key (if any). This way you can control in full detail what can do the operator and how to make the message more user friendly.

You must check which value is returned by the function: if the user presses one of the buttons, GenericMessagePopup returns VAL_GENERIC_xxx; if the user cancels the message it returns VAL_GENERIC_POPUP_NO_CTRL. In the sample above, I am simply testing if the user presses button 1 ( if GenericMessagePopup (...) == VAL_GENERIC_POPUP_BTN1) but you may want to pass the result of this function to a switch statement if choices are present in the message that require more complex treatment.

Message Edited by Roberto Bozzolo on 05-18-2005 08:48 AM



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?
Message 4 of 4
(3,839 Views)