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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

create popup menu with button clik

ss-10-11-12
1-Newbie

create popup menu with button clik

can anybody help me how to create popup with button click.The popup must contains label,TextFeild and button.

2 REPLIES 2
sjuraj
13-Aquamarine
(To:ss-10-11-12)

Do you mean java (j-link) ?

sully7
13-Aquamarine
(To:ss-10-11-12)

Hi Sangavi,

A couple of quick questions

  • What version of Creo are you using?
  • What API are you using?
  • By "popup" - do you mean a "PopupMenu" as in what happens when you "right click" somewhere? or do you mean just a "dialog box" with a button?

If you are looking for an actual "Dialog" box - I would highly recommend using Creo's "UI Editor" to help create your dialog. It is quick and easy to create a dialog with the layout you want, and it will even auto-generate C++ code for you.

On the other hand... if you are using ProToolkit, and only need a dialog box with some "standard" buttons, then ProUIMessageDialogDisplay should do the trick.

"Standard buttons" include:

typedef enum pro_ui_message_button

{

  PRO_UI_MESSAGE_ABORT = 0, /* Abort from the appln */

  PRO_UI_MESSAGE_RETRY = 1, /* Retry the step */

  PRO_UI_MESSAGE_IGNORE = 2, /* Ignore the event */

  PRO_UI_MESSAGE_CONFIRM = 3, /* Confirm the event */

  PRO_UI_MESSAGE_YES = 4, /* confirm the event */

  PRO_UI_MESSAGE_NO = 5, /* disagree */

  PRO_UI_MESSAGE_OK = 6, /* acknowldge */

  PRO_UI_MESSAGE_CANCEL = 7 /* disacknowledge */

}

Some example code (NOTE: I haven't tested this - so hopefully it works haha):

ProError hello_world {

  ProError err = PRO_TK_NO_ERROR;

  ProUIMessageType message_type = PROUIMESSAGE_INFO;

  ProUIMessageButton *buttons;

  ProUIMessageButton ok_button = PRO_UI_MESSAGE_OK;

  ProUIMessageButton cancel_button = PRO_UI_MESSAGE_CANCEL;

  err = ProArrayAlloc(0, sizeof(ProUIMessageButton), 1, (ProArray*)&buttons);

  err = ProArrayObjectAdd((ProArray*)&buttons, -1, 1, &ok_button);

  err = ProArrayObjectAdd((ProArray*)&buttons, -1, 1, &cancel_button);

  ProUIMessageButton user_picked_this_one = PRO_UI_MESSAGE_CANCEL; // set an initial value just incase

  err = ProUIMessageDialogDisplay(message_type, L"Hello World", L"Hello, World!\nThis is a popup.", buttons, ok_button, &user_picked_this_one);

  if (err == PRO_TK_NO_ERROR && user_picked_this_one == PRO_UI_MESSAGE_OK) {

    return PRO_TK_NO_ERROR; // hooray! ^_^

  }

  return PRO_TK_USER_ABORT;

}

"pfcSession::UIShowMessageDialog" is the OTK (C++) equivalent.

Let me know if this works for you, and feel free to PM me if you have more questions.

Thanks,

James Sullivan

CadActive Technologies

President & Founder
CadActive Technologies - www.cadactive.com
Top Tags