Greetings All,

In certain instances I start a secondary tray application from my main application.

When I close my main application, I would like to close my secondary tray application as well if it is still in the tray.

Any ideas on how to do this?

Thanks to all who reply,
Mike

Find its window and send it a message?

When you start up your main program, register a message:

 FDmMsg := RegisterWindowMessage (PChar (MessageName));

When you close, tell the other program:

 other_window := FindWindow (PChar (AnimClassname), PChar (AnimCaption));
 if other_window = 0 then Exit;
 PostMessage (other_window, FDmMsg, 0, 0);

In the other app, connect to the message at startup:

   FDMmsg := RegisterWindowMessage (PChar (MessageName));
   Application.OnMessage := OnAppMessage;

and handle the message in the other app:

procedure TForm.OnAppMessage (var Msg: TMsg;  var Handled: boolean);
begin
 if Msg.Message = FDMmsg then
   begin
     Handled := True;
   end;
end;

Obviously, this is much more than simply killing the other app, it could be used for all sorts of communication, and it doesn't rely on your main program starting the other app either. I've left a few things for you to look up!

Cheers,
David
--
SatSignal software - quality software written to your requirements
Web:  http://www.satsignal.eu
Email: david-tay...@blueyonder.co.uk
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk

Reply via email to