Mega Code Archive

 
Categories / Delphi / API
 

How to prevent extended close options in your application

If you need to prevent the user to close the appl. from the close-button in the form, then you can use Joe F, Darley's way to do so. But you can also add this code to prevent [ALT]+[F4] and by right-clik on the appl. in the programme-bar. private { Private declarations } OkToClose: Boolean; {In the forms OnCloseQuery event:} procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose := OkToClose; end; {And in your own closebutton: ( if you want to have one )} procedure TForm1.CloseProgrammeClick(Sender: TObject); begin OkToClose := True; Close; end; This way you cannot close the appl. other than if you let the user by your own close-button. Well... There is one way to close it... You can close the appl. by press [Ctrl]+[Alt]+[Del] and then close it in progresses or in the Job-list for programmes...