Re: Program closure
- From: Jamie <jamie_5_not_valid_after_5_Please@xxxxxxxxxxx>
- Date: Sat, 24 Sep 2005 14:15:53 -0700
Tim Cogher wrote:
Hi everyone,
I am trying to force any users of my program to close it using the Exit menu item and not simply stop the program using the top right red cross icon ( in Win XP).
Everything I have tried doesn't work, either it stops the program exiting altogether or the program exits straight away.
What do I need to do to get this to work?
Kind regards,
Tim.
use a global variable to indicate if the exit function has to been processed in your app.
Process the WM_CLOSE message. and test for this variable flag. if it hasn't been set, then set the returned value as been handled! by you so not to allow it to be processed by the default code. below is a hooked message that you do in your form code in the public section. Public procedure WMCLOSE(var msg:Tmessage); Message WM_CLOSE; End;
procedure Tform1.WMCLOSE(Var msg:tmessage); Begin if not itsok then msg.Result := 1 else inherited;
End; -- below is test code i did to set the ok for exit- -- i set this value to false in the Oncreate event. --- procedure TForm1.Button1Click(Sender: TObject); begin Itsok := true; end;
doin this code, the user will get a no response when hitting the X..
-- Real Programmers Do things like this. http://webpages.charter.net/jamie_5
.
- References:
- Program closure
- From: Tim Cogher
- Program closure
- Prev by Date: Re: Program closure
- Next by Date: Auto-saving the registry
- Previous by thread: Re: Program closure
- Next by thread: Re: Program closure
- Index(es):