473,796 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable Windows Close Button

Hi
How do i disable windows close button in forms in C#

Regards
Saurabh
Nov 16 '05 #1
3 6135
Actually, you cannot disable it. What you can do is, place an image over the
button to hide it ( and do nothing when the image is clicked)

Ranjan
--
http://dotnetjunkies.com/weblog/dotnut


"Saurabh Sharma" <sa***********@ yahoo.com> wrote in message
news:#b******** ******@tk2msftn gp13.phx.gbl...
Hi
How do i disable windows close button in forms in C#

Regards
Saurabh

Nov 16 '05 #2
You said the same thing I was thinking of when you mentioned the bool.
You also might be able to test the value of the sender and compare it
to something to see where it came from and decide what to do. I cant
think of anything thats just a single click. You would think something
that simple would be in there. Keep us updated.

Nov 16 '05 #3
Hello

[DllImport("user 32.dll")]
private static extern int GetSystemMenu(i nt hwnd, int revert);

[DllImport("user 32.dll")]
private static extern int GetMenuItemCoun t(int menu);

[DllImport("user 32.dll")]
private static extern int RemoveMenu(int menu, int position, int flags);

protected void DisableCloseBut ton()
{
int menu = GetSystemMenu(H andle.ToInt32() , 0);
int count = GetMenuItemCoun t(menu);
RemoveMenu(menu , count - 1, MF_DISABLED | MF_BYPOSITION);
}

Aleksandar

"Saurabh Sharma" <sa***********@ yahoo.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi
How do i disable windows close button in forms in C#

Regards
Saurabh

Nov 16 '05 #4

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

Similar topics

29
9783
by: lori3laz | last post by:
How do you disable the right click>view source option on web pages so people can't view your coding and copy it? What's the html I need to include in my website to utilize this feature? Thank you.
3
2991
by: bobdydd | last post by:
Hi Everybody On Report Preview Does anyone know of a way to disable the Minimum, Maximum and Close buttons, so that the user cannot close by any other means that the Toolbar button that I have supplied. This is easy enough on Access 2000 FORMS in Properties>>Format etc, but this is not available on a REPORT.
24
4879
by: Agnes | last post by:
I need to disable the exit button in the form . However, the min. and max. button need to keep it How ? Thanks a lot From Agnes
12
65492
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!
0
1459
by: JP | last post by:
Is there a way to temporirly disable the X button (close) on a MODAL window in the web browser? We have cleanup code that needs to run after the user closes the modal window. This works fine if the user closes the window via a button I have placed on the page. If the user tries to close the window via the "X", then popup blockers potentially pervent then cleanup window from executing. Right now, clicking the X fires off the...
2
6823
by: ohadasor | last post by:
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.
3
6003
by: Richard Lewis Haggard | last post by:
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
4
3516
by: mhifd009 | last post by:
I have disabled a close button in the property section of a form (FRM1), as i open the form the close button has gone (i have programmed close button), but as i close the form, the form that opened FRM1 also has the close button disabled - and so does every form until i minimise a form and maximise again. I have also tried to disable controlbox property but doesnt seem to remove, min, max or close - is there somewhere else i need to set. ...
3
3974
by: Donald A. Fisher | last post by:
Hello. I've been working a vb project and have a form with a button on it that performs some actions after disabling the button when clicked: Code disabling button and starting actions: Private Sub btnCreateExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateExcel.Click Me.btnCreateExcel.Enabled = False Dim pCreateExcel As New ClassCreateExcel AddHandler pCreateExcel.CreateExcelCompleted, AddressOf...
0
9685
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
9533
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10239
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
10019
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...
1
7555
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
5447
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
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.