473,785 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable Ctrl+F4?

Is there an easy way to disable the hotkey sequence Control F4 or otherwise
prevent the action from killing off MDI child windows in VS05/WinForms 2?
I've already figured out how to get rid of the 'x' in the caption bar but
the hot key sequence is still allowing users to kill off MDI child windows,
which I need to prevent from happening.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Nov 7 '06 #1
3 6002
Add code to the Closing evening for the child form and set e.cancel =
true; in those cases you don't want it to close.
Richard Lewis Haggard wrote:
Is there an easy way to disable the hotkey sequence Control F4 or otherwise
prevent the action from killing off MDI child windows in VS05/WinForms 2?
I've already figured out how to get rid of the 'x' in the caption bar but
the hot key sequence is still allowing users to kill off MDI child windows,
which I need to prevent from happening.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Nov 7 '06 #2

"DeveloperX " <nn*****@operam ail.comwrote in message
news:11******** ************@m7 g2000cwm.google groups.com...
Add code to the Closing evening for the child form and set e.cancel =
true; in those cases you don't want it to close.
Use the FormClosing event so you get CloseReason:

ApplicationExit Call The Exit method of the Application class was invoked.
FormOwnerClosin g The owner form is closing.
MdiFormClosing The parent form of this multiple document interface (MDI)
form is closing.
None The cause of the closure was not defined or could not be determined.
TaskManagerClos ing The Microsoft Windows Task Manager is closing the
application.
UserClosing The user is closing the form through the user interface (UI),
for example by clicking the Close button on the form window, selecting Close
from the window's control menu, or pressing ALT+F4.
WindowsShutDown The operating system is closing all applications before
shutting down.

Then test for UserClosing
>
Richard Lewis Haggard wrote:
>Is there an easy way to disable the hotkey sequence Control F4 or
otherwise
prevent the action from killing off MDI child windows in VS05/WinForms 2?
I've already figured out how to get rid of the 'x' in the caption bar but
the hot key sequence is still allowing users to kill off MDI child
windows,
which I need to prevent from happening.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Nov 7 '06 #3
Thanks for the suggestions. However, there was a problem in that the MDI
child forms were not being built by me and so I did not have control over
what the classes contained and couldn't enforce that all of the individual
MDI children implement their own protection against user closing. It turned
out that there is an easier way to handle the situation. Each MDI child has
an event notification list that is happy to accept an additional event
handler that resides in the main application. At the time that I created the
MDI child window(s) I also appended my own handler to the child's event
notification list. This gives something like this:

// In the code that creates an MDI child...
childForm.FormC losing += New FormClosingEven tHandler(
ChildFormClosin gEventhandler );

// Later in the module, the actual event handler itself...
public void ChildFormClosin gEventHandler(O bject sender, FormClosingEven tArgs
e)
{
if (CloseReason.Us erClosing == e.CloseReason)
e.Cancel = true;
}

Works like a champ!
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Ben Voigt" <rb*@nospam.nos pamwrote in message
news:ey******** ******@TK2MSFTN GP03.phx.gbl...
>
"DeveloperX " <nn*****@operam ail.comwrote in message
news:11******** ************@m7 g2000cwm.google groups.com...
>Add code to the Closing evening for the child form and set e.cancel =
true; in those cases you don't want it to close.

Use the FormClosing event so you get CloseReason:

ApplicationExit Call The Exit method of the Application class was invoked.
FormOwnerClosin g The owner form is closing.
MdiFormClosing The parent form of this multiple document interface (MDI)
form is closing.
None The cause of the closure was not defined or could not be determined.
TaskManagerClos ing The Microsoft Windows Task Manager is closing the
application.
UserClosing The user is closing the form through the user interface (UI),
for example by clicking the Close button on the form window, selecting
Close from the window's control menu, or pressing ALT+F4.
WindowsShutDown The operating system is closing all applications before
shutting down.

Then test for UserClosing
>>
Richard Lewis Haggard wrote:
>>Is there an easy way to disable the hotkey sequence Control F4 or
otherwise
prevent the action from killing off MDI child windows in VS05/WinForms
2?
I've already figured out how to get rid of the 'x' in the caption bar
but
the hot key sequence is still allowing users to kill off MDI child
windows,
which I need to prevent from happening.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com


Dec 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4672
by: Stefan | last post by:
Hy, a have an application and i must disable the follow combination of keys: ALT+F4 ALT+TAB CTRL+ALT+DEL CTRL+ESC. For ALT+F4 i can disable the conbination with: protected override System.Boolean ProcessCmdKey(ref System.Windows.Forms.Message msg,System.Windows.Forms.Keys keyData) {
3
44032
by: Stefan | last post by:
Hy, i have an app and i must disable this combination: ALT+F4; CTRL+ALT+DEL; CTRL+ESC;ALT+TAB like this: i find something on Internet and i can block ALT+F4 protected override System.Boolean ProcessCmdKey(ref System.Windows.Forms.Message msg,System.Windows.Forms.Keys keyData)
1
5787
by: karunakar | last post by:
Hi all Just i want capture the with "Ctrl" (Key bord function) + any F1 or F4 In windows application How can capture the event in C# .net Regards, Venu
2
3901
by: Mike Nooney | last post by:
How do I disable the "X" in the upper right hand corner of my Web Page. This is not for a windows form, but rather a web application. What I really need is to stop the user from unloading the page, if certain data is not present on the page. I know I should not use the Page_Unload event for this. I wouild like to disable the Close Button, or putting some extra validation behind a certain event, which event I am not sure. Any help would...
1
3204
by: Dante | last post by:
When your selected on a combo box, and hit F4, it shows the drop down list. So how do i stop the F4 key from bringing up the drop down list on a combo box?
7
2630
by: Michael Maes | last post by:
Hello, ALT+F4 is the shortcut to close a form. When I use this shortcut in an MDI enviroment, the application is closed, so obviously the shortcut applies to the 'Container' and not to the 'Childform'. What would be the best practice to capture this event and close the active child instead of the container (thus trying to end the application). --
3
12001
by: vanya | last post by:
i have been tryin to program(javascript) to disable the following keystroke combinations CTRL+O or CTRL+L Go to a new location (O = 79 L = 76) CTRL+S Save the current page ( S = 83) CTRL+E Open Search in Explorer bar (E = 69) CTRL+I Open Favorites in Explorer bar (I = 73) CTRL+H Open History in Explorer bar (H=72) CTRL+ click In History or Favorites bars, open multiple CTRL+LEFT ARROW When in the Address bar, move...
1
2680
hidash
by: hidash | last post by:
hi all, i want to disable the keys in keyboard for my webpage created using jsp. i need to make disable i) Alt+Tab ii) Alt+Esc iii) Ctrl+Tab iv) Alt+F4 v) Ctrl+P
1
1502
by: vasanthiraajan | last post by:
I need to capture the "Ctrl+F4" in widows application
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.