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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Abort loop on ProUIPushbutton

LarsZiegler
8-Gravel

Abort loop on ProUIPushbutton

Hello,

I have to do some updates on instances of a big family table (ca. 1500 items).


In a synchrone application I create a ProUIDialog for special settings for the job,
and then I start the job clicking on an ProUIPushbutton.


Now, while the for-loop ist working, the dialog is not active and i can't press any body to abort?


What do I have to do to get these functionality to my application?


Any ideas?



Thanks for help!



Greetings Lars



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.
7 REPLIES 7


Lars -

I think it's perfectly reasonable that you want to do this:

> Now, while the for-loop ist working, the dialog is not active
> and i can't press any body to abort?
> What do I have to do to get these functionality to my application?

As far as I know, you need a multi-threaded application to do this,
something which Pro/Toolkit does not support. Here's a quote from
the Wildfire 4 Pro/Toolkit User Guide:

Although the library flags provide compatibility with
multithreaded components, Pro/TOOLKIT calls must be
made within a single thread. Pro/ENGINEER does not
respond to calls made from multiple threads.

Of course, I could be wrong about this. In fact, I would be
happy if someone could prove me wrong with a solution to your
problem.

Can anyone tell us that Lars is NOT a prisoner of single-threaded
programming?

|+| 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


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.









Do you mean you would like to abort the dialog in the for looping when there
is some error?

ProUIDialog has a style named as PROUIDIALOGSTYLE_WORKING, which is set as
API *ProUIDialogDialogstyleSet().* Its introduction is as following:

A transient dialog type is used only to display some state information,
usually referring to the progress of some kind of lengthy operation =
PROUIDIALOGSTYLE_WORKING; This should be the value for dialogs with progress
bars.
My using is as following:
1. After you press the button of your dialog to do loop, the progress bar is
displayed with a button of CANCEL.
2. The progress bar will be updated when the loop going on.
3. If you press CANCEL button, close the progress bar and abort the loop.

Hivan Yang
2011/8/30 Mark R Stallard <->

> Lars -
>
> I think it's perfectly reasonable that you want to do this:
>
> > Now, while the for-loop ist working, the dialog is not active
> > and i can't press any body to abort?
> > What do I have to do to get these functionality to my application?
>
> As far as I know, you need a multi-threaded application to do this,
> something which Pro/Toolkit does not support. Here's a quote from
> the Wildfire 4 Pro/Toolkit User Guide:
>
> Although the library flags provide compatibility with
> multithreaded components, Pro/TOOLKIT calls must be
> made within a single thread. Pro/ENGINEER does not
> respond to calls made from multiple threads.
>
> Of course, I could be wrong about this. In fact, I would be
> happy if someone could prove me wrong with a solution to your
> problem.
>
> Can anyone tell us that Lars is NOT a prisoner of single-threaded
> programming?
>
> |+| 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*

Hello,

thanks for the answers!


Have you tried that already?
That's what I've done, but it does not work.
I can't click the cancel button.


We are working on Wildfire 3.0.


Here an example:
The progressbardlg.res is in the Pro/ENGINEER text folder.


err = ProUIDialogCreate(DlgName, "progressbardlg");


err = ProUIPushbuttonActivateActionSet(DlgName, "ProgressBarStopButton", DlgCloseFunction, NULL);
err = ProUIDialogCloseActionSet(DlgName, DlgCloseFunction, NULL);


err = ProUIProgressbarMinintegerSet(DlgName, "ProgressBarDlgMeter", 0);
err = ProUIProgressbarMaxintegerSet(DlgName, "ProgressBarDlgMeter", 10);


err = ProUIDialogAboveactivewindowSet(DlgName, PRO_B_TRUE);
err = ProUIDialogDialogstyleSet(DlgName, PROUIDIALOGSTYLE_WORKING);
err = ProUIDialogActivate(DlgName, NULL);


for (int i = 0; i <= 10; i++)
{
err = ProUIProgressbarIntegerSet(DlgName, "ProgressBarDlgMeter", i);
Sleep(200);
}



void DlgCloseFunction(char *Dialog, char *Control, ProAppData Daten)
{
ProUIDialogDestroy(Dialog);
}



Greetings, Lars

Hello,

1. The progress bar is created with API ProUIDialogCreate() before the loop.

2. Use API ProUIPushbuttonActivateActionSet() to set the call back
function for your stop button. The call back function will record
whether the button is pressed, and set its value to a bool variable.

3. At the beginning of each loop, check whether the bool variable (got
from step 2) is set to stop the loop.

4. API ProUIProgressbarIntegerSet() is used in the loop, which means
the progress bar will be updated for each loop. After this API, you
also need to call API ProUIDialogActivate() to activate the progress
bar dialog.

5. API ProUIDialogDestroy() is called to destroy the dialog after the loop.

Hivan Yang

2011/8/31 Lars Ziegler <lars.ziegler@de.mapal.com>:
> Hello,
>
> thanks for the answers!
>
> Have you tried that already?
> That's what I've done, but it does not work.
> I can't click the cancel button.
>
> Here an example:
>
> err = ProUIDialogCreate(DlgName, "progressbardlg");
>
> err = ProUIPushbuttonActivateActionSet(DlgName, "ProgressBarStopButton",
> DlgCloseFunction, NULL);
> err = ProUIDialogCloseActionSet(DlgName, DlgCloseFunction, NULL);
>
> err = ProUIProgressbarMinintegerSet(DlgName, "ProgressBarDlgMeter", 0);
> err = ProUIProgressbarMaxintegerSet(DlgName, "ProgressBarDlgMeter", 10);
>
> err = ProUIDialogAboveactivewindowSet(DlgName, PRO_B_TRUE);
> err = ProUIDialogDialogstyleSet(DlgName, PROUIDIALOGSTYLE_WORKING);
> err = ProUIDialogActivate(DlgName, NULL);
>
> for (int i = 0; i <= 10; i++)
> {
>  err = ProUIProgressbarIntegerSet(DlgName, "ProgressBarDlgMeter", i);
>  Sleep(200);
> }
>
>
>
> void DlgCloseFunction(char *Dialog, char *Control, ProAppData Daten)
> {
>  ProUIDialogDestroy(Dialog);
> }
>
>
>
> Greetings, Lars
>
> ----------

Hello,

I think that's what I did! Isn't it?

But while the loop ist running it is not possible to click the stop button!


Thanks!



Lars

Please see the step 3:

3. API ProUIProgressbarIntegerSet() is used in the loop, which means
the progress bar will be updated for each loop. After this API, you
also need to call API ProUIDialogActivate() to activate the progress
bar dialog.

API ProUIDialogActivate() should be called to activate the progress
bar dialog every loop. If the dialog is not activated, I think it
cannot be picked with the button. In your code, I did not see it.

In your code, there is no stop action for the loop after the stop
action from progress bar. Therefore, the dialog is only destroyed
after the loop finished.

I am not sure whether Sleep() will have affect for this.

Hivan Yang

2011/8/31 Lars Ziegler <lars.ziegler@de.mapal.com>:
> Hello,
>
> I think that's what I did! Isn't it?
>
> But while the loop ist running it is not possible to click the stop button!
>
> Thanks!
>
>
>
> Lars
>
> ----------

Perfect!


Thank you very much!
Now it works fine!



Greetings Lars

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags