473,660 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to remove/disable the form's close (X) button?

Hello,

I have an MDI child, which I need to be opened as long as the mainframe
is opened. The problem is that the user can close it using the X button
in the form's top-right edge.

How can I make this button disappear, or at least disabled?

I'm using C# with .NET Framework 2.0.

Thanks a lot!

Apr 9 '06 #1
2 6812
Just off the top of my head....

Override the WndProc so that you can trap the WM_NCHITTEST and WM_NCPAINT
messages.

Paint your own title bar without the close button in the handler for
WM_NCPAINT

Prevent the detection of the close button in the WM_NCHITTEST.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<oh******@netvi sion.net.il> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hello,

I have an MDI child, which I need to be opened as long as the mainframe
is opened. The problem is that the user can close it using the X button
in the form's top-right edge.

How can I make this button disappear, or at least disabled?

I'm using C# with .NET Framework 2.0.

Thanks a lot!

Apr 9 '06 #2
If you don't need the other icons from control box (minimize, maximize), you
can set the ControlBox property to false.
You can also override the Closing event of your form and cancel it (look at
closing reason and set e.Cancel = true;), which will not disable or let
disappear the button, but will not let anyone to close the form.

<oh******@netvi sion.net.il> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hello,

I have an MDI child, which I need to be opened as long as the mainframe
is opened. The problem is that the user can close it using the X button
in the form's top-right edge.

How can I make this button disappear, or at least disabled?

I'm using C# with .NET Framework 2.0.

Thanks a lot!

Apr 9 '06 #3

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

Similar topics

3
9864
by: JCharlie | last post by:
hi all. I´ve a problem with x button on internet explorer. Some users fills an informative form, they push x button and i don´t save the information. How can i disable the x button on internet explorer? I could a close window button and i could save the information when the users push this close button. Thank you.
0
2053
by: mawi | last post by:
Hello, Description: I create panels with some controls on a page using a new panel button. One of the controls on each panel is the "close panel" button that is supposed to close the panel it is on. This works fine only if one closes the panels from last panel. Otherwise two clicks is necessary for the last panel - ie, if you press add 3 times, close 2 and then 3 - two clicks on 3 will be necessary.
12
65469
by: Mika M | last post by:
Customer wants the Close (X)-button of the forms top right corner to be Disabled or removed from Windows Form-application, which is made using VB.NET, but leave MinimizeBox and MaximizeBox. I think this is not so clever to do like this way, but have to do like customer wants - so how to do this? It seems to be not just like changing property like with MinimizeBox and MaximizeBox. Any succestions? -- Thanks in advance!
2
2531
by: PamelaDV | last post by:
I am wondering if there is a way to disable the "X" used to close the Access application window? I know how to disable it for individual forms, but I would like to disable it for the application in general and force users to use a button on the switchboard to close (because I run important code on the close of the database from that button). Any ideas are always appreciated. Thanks!
2
2938
by: moi | last post by:
Hello, i have a Asp.net V2 login page with a password to enter. In some case, a user could forget and tell IE to save its password : How to prevent it ? Is there a way to disable it ? to block it ? Or could i create a button that save another text (replace) the cached password ? the user will be prompted to click the button to remove its cached password .... how to do it ?
1
3227
by: Kirsty | last post by:
Hi again, I'm new to VBA and would really appreciate your help. I have disabled the "X" close button and created a Close button, which I want to disable as a Form_Dirty event. So that users can only Close the form if they haven't made changes or have Saved their changes. However, as soon as I dirty the form, I get an error message pointing at this code: Private Sub Form_Dirty(Cancel As Integer) cmdClose.Enabled = False
1
2313
by: kenzs | last post by:
Hi! how to disable close(x) button in web form, i want only close button,don't disable in maximize button ,minimize button
1
1215
by: Brina | last post by:
I am currently writing an application and need to remove the close option from the form (The x button at the top right). I see that there are many examples of how to disable the close button and how to remove all the buttons. But for my application I would like to have only the minimize option available and thus the examples I have seen for VB.net will not help. Does anybody know how to just remove the close button? Thanks
4
2484
by: sasimca007 | last post by:
Hello friends, In my project, i am opening a window with javascript, in that new window i am providing a link to close that window, then there is no use of default close button of that window. So, i want how to disable or remove that close button of that window through javascript?
0
8851
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
8754
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...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
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
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.