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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alt+F4 2

Status
Not open for further replies.

ShyFox

Programmer
Mar 22, 2003
210
ES
Hy,
Have a tiny litle question.
How can I make my application not to respond to a brutal Alt+F4?[bigears]
And can I make my app invisible from the task manager?
Regards
 
Mike,
Thank you for the link. You helped a lot. Now, about Alt+F4, where must I insert this code. I tried inserting into main form's KeyPress Event. It doesn't work. Must I insert it in the main program? Or other event?

Regards
 
ShyFox

Must I insert it in the main program? Or other event?

Main program.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Perhaps a better way to prevent this kind of shutdown would be to use

ON SHUTDOWN Do CloseMyProg

PROC CloseMyProg
* if you want to close:
QUIT
* if you don't want to close, just:
RETURN
 
WGCS

Have you tested ATL+F4 with your suggestion? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yup... though I only showed pseudocode for the actual routine... this will display a messagebox before closing, and not close if you choose No:

ON SHUTDOWN do Closeit
Code:
* Put this in a file called CloseIt.prg
#define MBRYES      6
#define MBRNO       7
#define MBXYESNO    4
PROC CloseIt
If messageBoX('are you sure?',mbxYesNo)=mbrYes
  QUIT
endif
RETURN
 
wgcs

Yup... though I only showed pseudocode for the actual routine... this will display a messagebox before closing, and not close if you choose No:

Interresting that VFP would take over a Windows command...
Star for you for testing it.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
It's not really a windows command: the Alt+F4 is the Accelerator key for the Close command on the system menu in what used to be the "minus" menu in the top left corner of the application window (Win3.1) and is now the "icon" system menu in the same spot.

That close command just sends the normal "WM_CLOSE" message to the application, which is the same message sent when you click the "X" in the top right corner... and both are trapped by VFP and the ON SHUTDOWN command is run.

This uses the "normal" path instead of making VFP try to trap the ALT+F4 key before it's own accelerator key catches the keypress, which seems to work, anyway, too.
 
wgcs

It's not really a windows command:

I just meant that if you have nothing running and you click on your desktop, and use ALT-F4 it will prompt the shutdown screen.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
That sends a WM_CLOSE message to the Program Manager window ... just like:

Code:
DECLARE INTEGER FindWindow in win32api as apiFindWindow ;
 STRING @cClass, STRING cName

Declare INTEGER SendMessage in user32 ;
  as apiSendMessage INTEGER hWnd, INTEGER nMsg, ;
  INTEGER nParam1, INTEGER nParam2

DECLARE INTEGER GetDesktopWindow in Win32Api
whnd=getDesktopWindow()
?"Desktop ",whnd
whnd=apiFindWindow( 0,"Program Manager")
?"Program Manager ",whnd

apiSendMessage( wHnd, 0x10, 0,0 )  && 0x10=WM_CLOSE

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top