Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable close button on forms 1

Status
Not open for further replies.
You'll also want to disable Alt-Shift-F4, which will close down your program (even with the border icon disabled).

To do so, add the Keydown handler at the form level that catches this key combination.

so using your example, you'd add:
Code:
procedure TMain_Form.FormKeyDown(Sender: TObject; var Key: Word; shift: TShiftState);
begin
   if ((not fCloseButtonEnabled) and (Key = VK_F4) and (ssAlt in Shift)) then
      Key := 0;
end;
 
Thank you, great point. My goal is to soon make a shell form which includes all this extra functionality. I can make another property similar to this called "AllowClose" which takes all necessary steps to prevent user from closing the form.

I started experimenting with this subject while building an updater program, where during the update process, bad things could happen if the user decides to try to close the window.

JD Solutions
 
That's exactly what I use it for. One more thing that I add to my process is that I disable the screensaver while the process is running.
 
Well screensaver isn't too important in my case, but good idea. This sounds like more of something to put on the Application level, not the Form.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top