/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ #include <ProToolkit.h> #include <ProUIDialog.h> #include <ProUIPushbutton.h> #define OK 1 #define CANCEL 0 int UsrConfirmAction(char *question, ProBoolean *confirm); /*-----------------------------------------------------------------*\ Example function to show how UsrConfirmAction() is used \*-----------------------------------------------------------------*/ int UsrExample() { ProBoolean confirm; UsrConfirmAction("Do you really want to delete the table?", &confirm); } /*====================================================================*\ FUNCTION : UsrOKAction() PURPOSE : Action function for the OK button \*====================================================================*/ static void UsrOKAction( char *dialog, char *component, ProAppData data) { ProUIDialogExit(dialog, OK); } /*====================================================================*\ FUNCTION : UsrCancelAction() PURPOSE : Action function for the Cancel button \*====================================================================*/ static void UsrCancelAction( char *dialog, char *component, ProAppData data) { ProUIDialogExit(dialog, CANCEL); } /*====================================================================*\ FUNCTION : UsrConfirmAction() PURPOSE : Utility to prompt the user with question, and OK and Cancel buttons. \*====================================================================*/ int UsrConfirmAction( char *question, ProBoolean *confirm) { ProLine wline; int status; /*--------------------------------------------------------------------*\ Load the dialog from the resource file \*--------------------------------------------------------------------*/ ProUIDialogCreate("confirm","confirm"); /*--------------------------------------------------------------------*\ Set the OK and Cancel button actions \*--------------------------------------------------------------------*/ ProUIPushbuttonActivateActionSet("confirm","OK",UsrOKAction, NULL); ProUIPushbuttonActivateActionSet("confirm","Cancel",UsrCancelAction, NULL); /*--------------------------------------------------------------------*\ Set the Question test in the label \*--------------------------------------------------------------------*/ ProStringToWstring(wline, question); ProUILabelTextSet("confirm","Question",wline); /*--------------------------------------------------------------------*\ Display and activate the dialog \*--------------------------------------------------------------------*/ ProUIDialogActivate("confirm", &status); /*--------------------------------------------------------------------*\ Set confirm according to which button was used to close the dialog \*--------------------------------------------------------------------*/ *confirm = (status == OK) ? PRO_B_TRUE : PRO_B_FALSE; /*--------------------------------------------------------------------*\ Remove the dialog from memory \*--------------------------------------------------------------------*/ ProUIDialogDestroy("confirm"); return(1); }