BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

stopping Button1Click from external

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Martin Weghaus
Guest





PostPosted: Tue Mar 22, 2005 9:32 am    Post subject: stopping Button1Click from external Reply with 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?

bye
martin


Back to top
Andrue Cope [TeamB]
Guest





PostPosted: Tue Mar 22, 2005 10:06 am    Post subject: Re: stopping Button1Click from external Reply with quote



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





PostPosted: Tue Mar 22, 2005 10:10 am    Post subject: Re: stopping Button1Click from external Reply with quote



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





PostPosted: Tue Mar 22, 2005 10:14 am    Post subject: Re: stopping Button1Click from external Reply with quote


"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.