Closing my app...

Hi all

I want to allow other applications, eg MSAccess to close my application programmatically. What is the easiet way to achieve this?

Keith
LVL 1
keithcslAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
you should just make your app as normal.

but one thing to note is if an app send a wm_quit to your app and your app is working with important files or needs to save some settings ,or post data entrys you may want to listen for the wm_quit message and do your stuff and clean up then.if the apps send wm_close these events would be taken care of in your onclose handlers..
you could make something like:

 private
    procedure App_Message(var Msg: TMsg; var Handled: Boolean);

implementation

{$R *.DFM}

procedure TForm1.App_Message(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.hwnd = application.Handle) and
   (Msg.Message=WM_QUIT) then
begin
    //do clean up stuff
   //save settings etc..
      Handled := True;
    end
else
 Handled := False;  
end;


formcreate event:
 application.onmessage := app_message;

0
 
keithcslAuthor Commented:
Edited text of question.
0
 
kretzschmarCommented:
hi keithcsl,

? what about,
that the others app send a simple wm_close message to your mainform-handle (if possible) ?

is your app also started from the other apps?

meikl
0
 
intheCommented:
hello..anything further you need?
0
 
keithcslAuthor Commented:
thanks inthe

sorry i did not get back earlier. it works well...

Keith
0
All Courses

From novice to tech pro — start learning today.