cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

OTK C++ - Creation of Dialog fails the second time

ptc-2162721
7-Bedrock

OTK C++ - Creation of Dialog fails the second time

I try to create a simple dialog, which will be closed by pressing the Cancel-Button.

The first time the dialog is started, everything works correct.

uifcCreateDialog, uifcActivateDialog, uifcExitDialog and uifcDestroyDialog return 0 and

no exception is thrown.

But starting the dialog the second time fails. Calling uifcCreateDialog returns -1 and the

dialog is not created. For some hints I would be grateful.

Thanks in advance.

 

Versions:

Creo Parametric 3.0 - 64 bit

Windows 7 64 Bit

C++ Object Toolkit

ACCEPTED SOLUTION

Accepted Solutions

The second parameter of uifcCreateDialog is the resource. I tried to use a relative or absolute path to this file, which results in this strange behaviour. Copying the file to the right place and using only the name without extension solved the problem for me.

View solution in original post

6 REPLIES 6

The second parameter of uifcCreateDialog is the resource. I tried to use a relative or absolute path to this file, which results in this strange behaviour. Copying the file to the right place and using only the name without extension solved the problem for me.

sully7
14-Alexandrite
(To:ptc-2162721)

Does this mean that it did not work with a subdirectory? I'm experiencing a similar issue now, and have my resource file located in a subdirectory from the "text/resource" folder.

President & Founder
CadActive Technologies - www.cadactive.com
MurphyMin
12-Amethyst
(To:sully7)

The Dialog resource file should be in your peoject directory ./txt/resource/GearTest.res

The following works (for me, and should work with all Creo versions at least up to 5.0):

Dialog resource file (name and location relevant!):

<protk.dat text_dir>\resource\my_dialog.res

In the my_dialog.res, the dialog name must match the file name without extension:

! Resource file for my_dialog
(Dialog my_dialog
    (Components
...
    )
...
)

The Pro/TOOLKIT C/C++ code creating and destroying the dialog:

#define  MY_DIALOG_NAME "my_dialog"
int iDlgExitStatus = -1;
pErr = ProUIDialogCreate(MY_DIALOG_NAME, MY_DIALOG_NAME);
// Setup the dialog and callbacks, activating the dialog, etc. ...
pErr = ProUIDialogCloseActionSet(MY_DIALOG_NAME, MyDlg_Act_Cancel, NULL);
pErr = ProUIDialogActivate(MY_DIALOG_NAME, &iDlgExitStatus);
pErr = ProUIDialogDestroy(MY_DIALOG_NAME);

// Callback function for simple closing action
static void MyDlg_Act_Cancel(char* cDialog, char* cComponent, ProAppData pAppData){
ProError            pErr = PRO_TK_NO_ERROR;        //    Creo return value
    pErr = ProUIDialogExit(cDialog, PRO_TK_USER_ABORT);
        if ( pErr != PRO_TK_NO_ERROR ) {
            //    Error handling...
        }
    return;
}

(Even if this answer may be too late for the OP, others could benefit from it.)

The solution says to put the file in the "right place, " but it's unclear where that is. I can get the dialog to appear using the absolute path, but I'm still seeing the issue when I try to load the dialog a second time. I've tried a bunch of combinations of with/without the file extension, moving the .res file to different locations, etc. without any luck. Any help will be greatly appreciated. @ptc-2162721 

GiuseppeMicheli
5-Regular Member
(To:Rmorin)

"Right place" for resources is the "text\language\resource" path of your application.

But I think that if you can correctly run your code the first time but you cannot do a second one, the problem lies somewhere else.

I suggest you to be sure you correctly free resources before invoking it again:

- deleting listeners (see the "delete session" of the authomatic C++ code which is exported by the UI Editor tool);

- exiting and destroyng the dialog invoking both the methods uifcExitDialog and uifcDestroyDialog within the destructor of a class (if you ever use it):

~classHandlingDialog::classHandlingDialog() {
ProError status;
try {
uifcExitDialog(DIALOG_NAME, status);
  status = uifcDestroyDialog(DIALOG_NAME);
}
catch(...) {
status = PRO_TK_GENERAL_ERROR;
}
return status;
}
Announcements


Top Tags