Board index » cppbuilder » How to send a message to all forms?

How to send a message to all forms?


2003-09-18 10:08:26 PM
cppbuilder57
I have an application where a menu or button on any of several forms can
start a process that may spawn a number of threads. The threads use the
TThread class.
When the process starts, I'd like to notify all the forms which might
execute the process, so that they can disable the menu items which start
the process. (Only one instance of the process can be running at any one
time.) Obviously I can call methods in all the forms, but I'm fairly
sure that will become a maintenance nightmare.
When the last thread has stopped, I'd like to notify all the forms so
they can re-enable the menus. Currently I use a timer for this, which
checks the count of threads running.
Is there a better way?
--
Simon Elliott
www.ctsn.co.uk/
 
 

Re:How to send a message to all forms?

"Simon Elliott" < XXXX@XXXXX.COM >wrote in message
Quote
When the process starts, I'd like to notify all the forms which
might execute the process, so that they can disable the menu
items which start the process.
Have a look at TActionManager and TAction. You can define a TAction that
handles the actual starting of the process via its OnExecute event, and then
assign the TAction to the Action property of all your menu items and buttons
(make sure that you clear their own OnClick events so the TAction is
actually used). Then all you have to do is enable/disable the single
TAction directly and all of the menu items and buttons will automatically be
updated accordingly.
Gambit