Board index » cppbuilder » refresh of speed buttons

refresh of speed buttons

Hello everybody,

I am using speed-buttons located on a tool-bar. Together with the
event OnUpdate oft the associated TAction I can ensure that the status
of the buttons are refreshed as soon as the application goes idle.

When my application is running within a loop I need to respond to the
click of the stop-button. I can achieve this by periodically calling
Application->ProcessMessages();

The problem is to activate the Stop button just before the loop starts
Right now I am doing as follows :

InterruptedFlag=false;
ProcessingFlag = true;
Application->ProcessMessages();   // empty the message queue
Application->HandleMessage();       // go into idle state so that the
speed buttons can be refreshed
while(!InterruptedFlag)
    DoSomething();
ProcessingFlag = false;

Each time I am setting the ProcessingFlag to true and entering a loop,
I have to call the to functions ProcessMessages() and HandleMessage().

Is there any better solution ???

Thanks
Uwe

 

Re:refresh of speed buttons


: "Uwe Barthoff" <Uwe.Barth...@ibm.net> wrote:

Quote
>Each time I am setting the ProcessingFlag to true and entering a loop,
>I have to call the to functions ProcessMessages() and HandleMessage().

>Is there any better solution ???

Use a thread for your processing loop. You are currently using a kludge /
hack to achieve the same effect.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Re:refresh of speed buttons


Hello Stefan,
Thanks for the advice.I was actually thinking about the threads but
this seems to be a lot of work if the program has many different
functions (processing loops) but always the same set of speed buttons.
This would mean that I have to design many different threads.

Wouldn't it be better to have just one thread taking care of the spedd
buttons ? But then, how can I direct events like OnClick to that
thread ?

Thanks
Uwe

Re:refresh of speed buttons


: "Uwe Barthoff" <Uwe.Barth...@ibm.net> wrote:

Quote
>Wouldn't it be better to have just one thread taking care of the spedd
>buttons ?

No, because the VCL is not thread-safe.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Other Threads