Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Mar : Use ALT-X to end program and it boops -- why?

www.cryer.info
Managed Newsgroup Archive

Use ALT-X to end program and it boops -- why?

Subject:Use ALT-X to end program and it boops -- why?
Posted by:"Joe H" (joedot..@att.net)
Date:28 Mar 2008 15:15:25

If you make a new project, set an on keydown event and in it put

procedure tForm1.formKeyDown(sender: tObject; var key: word; shift:
tShiftstate);
begin
  if (key = ord('X') and (ssALT in shift) then
    close;
end;

Whether you have the form's keypreview true or false it does this.

Run it and type alt+X and the program terminates properly but windows
does the boop sound on xpPro (or chime on vista). Anyone know why and
how this could be suppressed? I've tried changing the close to
postquitmessage and that made no difference. I've used this in a number
of child forms and they do not boop when they close this way--it's only
the main form.

I've also tried setting the key value to 0 and ssShift = [] to no
avail. I really like using alt+x as an alternate way to close windows
(because it won't try to close the operating system).

I wouldn't be surprised if the answer is embarassingly simple but I
can't think of what it might be.

thanks.

Replies:

www.cryer.info
Managed Newsgroup Archive