473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 6772
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******@netvision.net.il> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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******@netvision.net.il> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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
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...
0
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...
12
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...
2
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...
2
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...
1
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...
1
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
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.