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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

ProUIDialog Initialization

pwilliams-3
11-Garnet

ProUIDialog Initialization

All,
I am creating a dialog box and filling controls before the dialog is
displayed (before the call to ProUIDialogActivate). During this
initialization I am setting the names and labels for a ProUIOptionmenu.
Additionally I would like to pre select one of the options. So, I am
calling ProUIOptionmenuSelectednamesSet and this is crashing Pro/ENGINEER.
I am also trying to set the label for my tree control by using
ProUITreeLabelAdd and that is returning an error. So my question is, can
I pre select options and set other things before the dialog is displayed?

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)
-

TU/M12/8
6221 S Palo Verde Rd
Tucson, AZ 85706 USA
www.raytheon.com



This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.

This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
8 REPLIES 8

Sorry, WF 4.0 M130.

One more curious thing. If I store the name of my dialog in an STL string
and then pass it to ProUIDialogCreate it fails. Is this a unicode issue?

string m_strDlgName = "MyDialog";

ProUIDialogCreate((char*)m_strDlgName.c_str(),
(char*)m_strDlgName.c_str());

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)
-

TU/M12/8
6221 S Palo Verde Rd
Tucson, AZ 85706 USA
www.raytheon.com



This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.



Hi Patrick -

It sounds like Pro/Toolkit won't let you set ProUIOptionnmenu selection
before
the dialog is actually displayed:

> Additionally I would like to pre select one of the options. So, I am
> calling ProUIOptionmenuSelectednamesSet and this is crashing
Pro/ENGINEER.
> I am also trying to set the label for my tree control by using
ProUITreeLabelAdd
> and that is returning an error. So my question is, can I pre select
options
> and set other things before the dialog is displayed?

It's fine to populate the controls before displaying the dialog, but I
don't
have any dialog code handy where I set active selections before display.

My hunch is that specify an event handler with
ProUIDialogActivateActionSet()
and place your ProUIOptionmenuSelectednamesSet() call inside that event
handler. That's consistent with what I had to do with dashboard-based
code,
which use a similar interface to ProUIDialog.

|+| M a r k |+|

Mark Stallard
Rapid Response Development
information Solutions
Integrated Defense Systems
Raytheon Company



(business)
+1.978.436.6016
(cell)
+1.617.331.5443
(tie line)
239.6016
-

880 Technology Drive
Billerica, MA 01821
www.raytheon.com


This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.





Mark,
That was my initial thought but I only want to pre select the option once
before display. As you can see from the documentation that event fires
repeatedly.

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)
-

TU/M12/8
6221 S Palo Verde Rd
Tucson, AZ 85706 USA
www.raytheon.com



This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.




Patrick -

I think it's very likely that your run-time failures are caused by a
executing ProUIOptionmenuNamesSet before the dialog is displayed, and
that you need an event handler. I suggest you try an event handler
to see if it resolves the crashing.

The only other events that might apply are ProUIDialogPremanagenotify
and ProUIDialogPostmanagenotify. One of them might be exactly what you
need (a reasonable assumption), or you might have to add some token
variable and logic to ensure that you call ProUIOptionmenuNamesSet only
when you want to (not so reasonable, but not too unusual, either).

|+| M a r k |+|

Mark Stallard
Rapid Response Development
information Solutions
Integrated Defense Systems
Raytheon Company




(business)
+1.978.436.6016
(cell)
+1.617.331.5443
(tie line)
239.6016

-



880 Technology Drive
Billerica, MA 01821
www.raytheon.com


(Embedded image moved to file: pic24659.gif)Raytheon Sustainability

This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this message
in error, please so advise the sender by reply e-mail and delete this
message. Thank you for your cooperation.










Here is the code that reproduces the issue in WF 4.0. Is this a unicode
problem?

int ProUIOptionmenuSelectednamesSetAction(uiCmdCmdId command, uiCmdValue
*p_value, void *p_push_command_data) {

char *szDlgName =
"ProUIOptionmenuSelectednamesSetDlg",
**aszNames
= NULL;
wchar_t **awszLabels =
NULL;
int i = 0,
nUnitSystemSize = 0,
nDlgStatus
= 0;
ProError pro_error =
PRO_TK_NO_ERROR;
ProMdl pro_mdl = NULL;
ProUnitsystem *pro_aUnitSystem = NULL,
pro_unitSystem;

//Create the dialog
pro_error = ProUIDialogCreate(szDlgName, szDlgName);

//Set the callback for the Close button
pro_error = ProUIDialogCloseActionSet(szDlgName, PBCloseAction,
NULL);

//Get the current model
pro_error = ProMdlCurrentGet(&pro_mdl);

//Allocate the array
pro_error = ProArrayAlloc(0, sizeof(ProUnitsystem), 1,
(ProArray*)&pro_aUnitSystem);

//Collect model unit systems
pro_error = ProMdlUnitsystemsCollect(pro_mdl, &pro_aUnitSystem);

//Get the size of the array
pro_error = ProArraySizeGet((ProArray)pro_aUnitSystem,
&nUnitSystemSize);

//Allocate option menu arrays
aszNames = (char**)calloc(nUnitSystemSize, sizeof(char*));
awszLabels = (wchar_t**)calloc(nUnitSystemSize, sizeof(wchar_t*));

//Iterate through the unit systems found
for(i=0;i<nunitsystemsize;i++) {<br="/>
aszNames[i] = (char
*)calloc(wcslen(pro_aUnitSystem[i].name) + 1, sizeof(char));
ProTKSprintf(aszNames[i], "%S", pro_aUnitSystem[i].name);
awszLabels[i] = _wcsdup(pro_aUnitSystem[i].name);
}

//Set the option menu names
pro_error = ProUIOptionmenuNamesSet(szDlgName, "optUnits",
nUnitSystemSize, aszNames);

//Set the option menu labesl
pro_error = ProUIOptionmenuLabelsSet(szDlgName, "optUnits",
nUnitSystemSize, awszLabels);

//Free the option menu arrays
for(i=0;i<nunitsystemsize;i++) {<br="/> free(aszNames[i]);
free(awszLabels[i]);
}
free(aszNames);
free(awszLabels);

//Free the array
pro_error = ProArrayFree((ProArray*)&pro_aUnitSystem);

//Get the principal unit system
pro_error = ProMdlPrincipalunitsystemGet(pro_mdl,
&pro_unitSystem);

aszNames = (char**)calloc(1, sizeof(char*));
aszNames[i] = (char*)calloc(PRO_NAME_SIZE, sizeof(char));
ProWstringToString(aszNames[i], pro_unitSystem.name);

//Set the selected unit system
pro_error = ProUIOptionmenuSelectednamesSet(szDlgName, "optUnits",
1, aszNames);

free(aszNames[i]);
free(aszNames);

//Display the dialog
pro_error = ProUIDialogActivate(szDlgName, &nDlgStatus);

//Destroy the dialog
pro_error = ProUIDialogDestroy(szDlgName);

return PRO_TK_NO_ERROR;
}

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)
-

TU/M12/8
6221 S Palo Verde Rd
Tucson, AZ 85706 USA
www.raytheon.com



This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.



Patrick -

I can't say whether this is an 8- vs 16-bit text issue. If are still
trying to resolve any crashing issues, I suggest that you move your
calls to free() and other deallocation functions to the end of the
the function, after the dialog is closed.

|+| M a r k |+|

Mark Stallard
Rapid Response Development
information Solutions
Integrated Defense Systems
Raytheon Company



(business)
+1.978.436.6016
(cell)
+1.617.331.5443
(tie line)
239.6016
-

880 Technology Drive
Billerica, MA 01821
www.raytheon.com


This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.





LarsZiegler
5-Regular Member
(To:pwilliams-3)

Change the i to 0 in the lines:

aszNames = (char**)calloc(1, sizeof(char*)); aszNames[0] = (char*)calloc(PRO_NAME_SIZE, sizeof(char));

ProWstringToString(aszNames[0], pro_unitSystem.name);

//Set the selected unit system

err = ProUIOptionmenuSelectednamesSet(szDlgName, "optUnits", 1, aszNames);

free(aszNames[0]);

free(aszNames);

Greetings Lars

Thanks Lars, I wasn't very thorough in my coding. I think it was a
copy/paste error. That worked great.

Patrick Williams
Sr. Systems Engineer II
Mechanical Engineering Solutions
Missile Systems
Raytheon Company

+1 520.545.6995 (business)
+1 520.545.6399 (fax)
-

TU/M12/8
6221 S Palo Verde Rd
Tucson, AZ 85706 USA
www.raytheon.com



This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this
message in error, please so advise the sender by reply e-mail and delete
this message. Thank you for your cooperation.



Top Tags