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