Languages :: Delphi :: Stop IE popups & Disable Alt + F4 |
|||
| By: digitaltree |
Date: 20/07/2003 00:00:00 |
Points: 70 | Status: Answered Quality : Excellent |
|
I want some code that will stop IE popup windows and how to disable Alt + F4 thanks |
|||
| By: VGR | Date: 20/07/2003 04:51:00 | Type : Comment |
|
| for Alt-F4, no way (it's the windows shortcut to "close window") unless you insatll a global hook. What you can do IN AN APPLICATION YOU DEVELOP is to handle Alt-F4 (or , better, the WM_* message for close request) and ignore it if some condition isn't there. Your application should be closeable anyway, don't you think ? ;-) For IE, the only solution I see is patching the executable. To stop the popup window, many solutions : 1) install the add-on CrazyBrowser 2) patch the executable 3) install a third-party "popup-killer" 4) change for a real browser, ie Mozilla Firebird : faster, more reliable, smaller footprint... <a href="http://texturizer.net/firebird/index.html">http://texturizer.net/firebird/index.html</a> |
|||
| By: digitaltree | Date: 21/07/2003 22:29:00 | Type : Comment |
|
| can you show me the code for the alt + f4 also is there a way to monitor if a popup ie window is active if so the cod ecould loop antil a popup is found then the code can stop? thanks |
|||
| By: VGR | Date: 21/07/2003 23:03:00 | Type : Comment |
|
| yes, with EnumerateWindows or a loop on FindWindow with the Caption searched for (or the application type). for Alt-F4 : With just one line of code, you can disable the Alt-F4 key combination in a Delphi application. Intercept all the keypresses at the level of the form, inspect which keys are pressed, and suppress the keys if Alt+F4 was pressed. The first thing that you have to do is to set the KeyPreview property of the form to "True". This can be done in the Object Inspector. That way, all the keypresses go to the form first, instead of for example to a menu, or to the component that has the focus,... Next, also in the Object Inspector, you create an OnKeyDown handler for the form. Next, add a line that inspects keyboard keys that are pressed and suppresses them if necessary: procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key = VK_F4) and (ssAlt in Shift) then Key := 0; end; If F4 and ALT are pressed together, this procedure "swallows" the key. Any other key combination is passed on automatically to the next level (to a menu, or to a TEdit, a TButton,...) copied from <a href="http://www.festra.com/wwwboard/messages/2206.html">http://www.festra.com/wwwboard/messages/2206.html</a> |
|||
| By: VGR | Date: 21/07/2003 23:04:00 | Type : Answer |
|
| or : To prevent the user from closing a form you can simply set CanClose to False in the CloseQuery event of the form, but this has two problems: 1. The Close button in the title bar and the Close menu item in the form's system menu are enabled giving the users the false sensation that they can close the form when actually they can't and then they complain that your application is not working properly. No comments! 2. In the CloseQuery event you don't have a direct way to know if the user is closing the form or if you are closing the form by code. You can disable these elements the "Close" menu item in the form's system menu. This is done by calling the EnableMenuItem API function (see the example below). Nonetheless, the user can still close the form using the Alt+F4 key combination, so we have to set the KeyPreview form property to True and write an event handler for the OnKeyDown event to cancel out this hot key. Here you have the source code: uses SysUtils, Windows; procedure TForm1.FormCreate(Sender: TObject); var hSysMenu: HMENU; begin hSysMenu := GetSystemMenu(Self.Handle, False); if hSysMenu <> 0 then begin EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND Or MF_GRAYED); DrawMenuBar(Self.Handle); end; KeyPreview := True; end; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key = VK_F4) and (ssAlt in Shift) then Key := 0; end; taken from <a href="http://www.latiumsoftware.com/en/delphi/00026.php">http://www.latiumsoftware.com/en/delphi/00026.php</a> |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








