I've tried returning 0 from windowproc when this is pressed, but it still closes the window.
Does anyone know of a way to prevent alt-f4 from closing the window?
I've tried returning 0 from windowproc when this is pressed, but it still closes the window.
Does anyone know of a way to prevent alt-f4 from closing the window?
One solution is to keep the window from closing via a boolean variable. For example, the program closes only when the user does it manually via menu. Otherwise, ignore the WM_CLOSE message.
Kuphryn
just so you know, that won't work if the user presses ctrl alt del...that's impossible to get around if it's a windows app because windows handles the execution of the program, hence the uses of messages (like wm_close).
PHP and XML
Let's talk about SAX
Check for SC_CLOSE flag in response to a WM_SYSCOMMAND msg. Send all other flags to DefWindowProc (or return FALSE if using a dialog) for default system handling.
Use GetSystemMenu to get a copy of the system(window) menu and gray out the 'Close Alt + F4' menuitem (assuming you have a visible system menu).
Hope that helps.
It's as simple as that.
Thanks alot
Originally posted by Waldo2k2
just so you know, that won't work if the user presses ctrl alt del...that's impossible to get around if it's a windows app because windows handles the execution of the program, hence the uses of messages (like wm_close).
Not really. You could block the use of ctrl alt del.
Really?Originally posted by golfinguy4
Not really. You could block the use of ctrl alt del.
I'm curious as to how that works...i didn't think windows would let you do it.
PHP and XML
Let's talk about SAX
It doesn't really let you.... You have to trick it into thinking that you are running a screensaver.
Look up SystemParametersInfo and the SPI_SETSCREENSAVEACTIVE option.
As far as I know - the SPI_SETSCREENSAVEACTIVE is ineffective in Win 2000 and XP......
That's correct. I just tried this on Xp:
GetErr() Displays return from GetLastError()Code:if(!SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0)) GetErr("SystemParametersInfo");
>> ust so you know, that won't work if the user presses ctrl alt del...that's impossible to get around if it's a windows app because windows handles the execution of the program, hence the uses of messages (like wm_close). <<
not true, you can use a keyboard hook if you want to disable key presses
I doubt that........I havent tested it....but on Win 2K and above, the CTL-ALT-DEL combination basically frezzes other process's access to the keyboard and mouse.......I think this applies to hooks tooOriginally posted by Okiesmokie
>> ust so you know, that won't work if the user presses ctrl alt del...that's impossible to get around if it's a windows app because windows handles the execution of the program, hence the uses of messages (like wm_close). <<
not true, you can use a keyboard hook if you want to disable key presses