| View previous topic :: View next topic |
| Author |
Message |
Martin Weghaus Guest
|
Posted: Tue Mar 22, 2005 9:32 am Post subject: stopping Button1Click from external |
|
|
I have a great loop in Button1Click. To stop it there is an global bool
STOP.
But while Button1Click is running I can not Click on another Button to set
Stop
Is there a function to tell the application to look for some events?
bye
martin
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Mar 22, 2005 10:06 am Post subject: Re: stopping Button1Click from external |
|
|
Martin Weghaus wrote:
| Quote: | Is there a function to tell the application to look for some events?
|
Not in the C++ language nor its standard libraries which is all this
section of the newsgroup is intended to deal with. If you are using the
Windows API then repost to .nativeapi but if you are using VCL
components then post to .vcl.components.using
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Helmut Giese Guest
|
Posted: Tue Mar 22, 2005 10:10 am Post subject: Re: stopping Button1Click from external |
|
|
Hi Martin,
| Quote: | I have a great loop in Button1Click. To stop it there is an global bool
STOP.
But while Button1Click is running I can not Click on another Button to set
Stop
Is there a function to tell the application to look for some events?
Application->ProcessMessages() should do what you want. |
But beware: If, while this loop is running, you click again on Button1
(ok, you won't, but some of your users will), this handler will get
invoked again - which is probably not a good idea.
So you should disable the button as the very first thing you do in
your event handler and re-enable it when leaving.
HTH
Helmut Giese
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Mar 22, 2005 10:14 am Post subject: Re: stopping Button1Click from external |
|
|
"Martin Weghaus" <mene (AT) weghaus (DOT) net> wrote:
| Quote: |
[...] Is there a function to tell the application to look
for some events?
|
Yes. Application->ProcessMessages(); That will allow the cancel
button click to get processed so that the bool STOP can be set
to true.
However, adding that to the loop will slow down the loop big
time if you execute it every itteration of the loop. What you
need is a loop counter so that you can ProcessMessages only
every so often. For example, the following does it every 100
itteration:
if( !(LoopCounter % 100) )
{
Application->ProcessMessages();
}
if( STOP )
{
// break;
}
~ JD
|
|
| Back to top |
|
 |
|