473,666 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to remove or disable Close (X)-button of the Form?

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!

Mika
Nov 21 '05 #1
12 65469
Mika,

When you are sure your users wants it and you are not distributing the
program too others, (because otherwise you will most probably directly be
confrontated with bug reports which are probably justifiable correct) you
can just use the closing event and set in that e.cancel = true (or false I
always am in doubt about the last just try).

I would in your situation let the user sign a contract that he wanted this.
What you can do as well is showing in a the messagebox from the clossing
event that this is by order from your client disabled. (A little more polite
however not to misunderstand text than of course).

Instead of that all you can as well overpaint the X (and keep the cancel)
however that will be a lot more work.

I hope this helps?

Cor
Nov 21 '05 #2
#Region " Windows Form Designer generated code "

'disables close
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
Const CS_NOCLOSE As Integer = &H200
cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
Return cp
End Get
End Property
"Mika M" wrote:
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!

Mika

Nov 21 '05 #3
Mark,

Nice, I never saw this one before (is now in my snippets)

Thanks

Cor
Nov 21 '05 #4
"Mika M" <mahmik_nospam@ removethis_luuk ku.com> schrieb:
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.


Add this to your form:

\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
Const CS_DBLCLKS As Int32 = &H8
Const CS_NOCLOSE As Int32 = &H200
cp.ClassStyle = CS_DBLCLKS Or CS_NOCLOSE
Return cp
End Get
End Property
///

Alternatively you can remove the according menu items from the system
menu using p/invoke.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
> #Region " Windows Form Designer generated code "

'disables close
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
Const CS_NOCLOSE As Integer = &H200
cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
Return cp
End Get
End Property


Thanks Mark! Seems to work like I need!

--
Mika
Nov 21 '05 #6
I had quite a discussion about this in GotDotNet a few months back:
http://www.gotdotnet.com/Community/M...&Page=1#248801

If you never want the Close Button to show then use the CreateParams method,
but if you want to toggle the state of the close button then this method is
no good, you will instead have to modify the Window Menu.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Mika,

When you are sure your users wants it and you are not distributing the
program too others, (because otherwise you will most probably directly be
confrontated with bug reports which are probably justifiable correct) you
can just use the closing event and set in that e.cancel = true (or false I
always am in doubt about the last just try).

I would in your situation let the user sign a contract that he wanted
this. What you can do as well is showing in a the messagebox from the
clossing event that this is by order from your client disabled. (A little
more polite however not to misunderstand text than of course).

Instead of that all you can as well overpaint the X (and keep the cancel)
however that will be a lot more work.

I hope this helps?

Cor

Nov 21 '05 #7
....and I thought you were always paying attention ;)

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
Mark,

Nice, I never saw this one before (is now in my snippets)

Thanks

Cor

Nov 21 '05 #8
Mick,

When I saw your article I thought I have to say Sorry Sorry Sorry however
you gave me the change here.

Until now I thought that I had seen only awfull painting solutions, because
this simple one I would have remembered me I thought.

Again Sorry Sorry Sorry

:-)))

Cor
Nov 21 '05 #9
No need to apologise. I just couldn't believe you hadn't seen it before
since it's been here several times in the past and I'm almost positive that
you've read every message since you started interacting with the group. By
the amount of responses you give it certainly looks that way.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:un******** ******@TK2MSFTN GP10.phx.gbl...
Mick,

When I saw your article I thought I have to say Sorry Sorry Sorry however
you gave me the change here.

Until now I thought that I had seen only awfull painting solutions,
because this simple one I would have remembered me I thought.

Again Sorry Sorry Sorry

:-)))

Cor

Nov 21 '05 #10

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

Similar topics

4
11680
by: Phil | last post by:
Hello all, Can anybody give me any ideas on how to disable a tab page within a tab control. I have a tab control tabClients with 3 pages. I would like to disable pages 2 & 3 when a certain condition is met. Thanks in Advance. Phil.
8
19127
by: Matt | last post by:
Hi everyone I was wondering if there was a way to disable a single database with having to shutdown mysql or rename tables? Thanks, Matt
3
2983
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.
6
10120
by: ron | last post by:
1. Can I disable a user control in a web page? 2. Can I disable the 'close' function on the top-right corner of a popup window, so I can use code-behind function to close the browser?
5
2865
by: Jonas | last post by:
I want to remove a remote access connection when a user logs out. The connection is a dial up isdn adapter. I can access the adapter via WMI namespace \root\microsoft\homenet, but i don´t find any way to delete it. Is it possible to do this or do i need to some pinvoke on rasapi32?
3
2226
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I use vb 2005 to create window app, and try to disable close button/item on the top right coner of window, can anyone can help this out? Thanks for yuor time, Martin
0
1075
by: Garg | last post by:
When you place your mouse over the calendar object in the events module it displays a tooltip that says "Calendar". Does anyone know how to remove/disable this tooltip?
9
3476
by: Laurent ARNAL | last post by:
Hi, I would like to know if there is a way to remove/disable .php handler when the request come from a specific Browser. I ask this because I use dreamweaver / webdav to edit my .php files. But when I try to open the .php file in dreamweaver, what I see if the result of the .php executions, not the .php source files. I know that you can create an Alias location "/dav", and disable the
6
2799
by: DhananjayPatki | last post by:
Hello, I wnat the code , how to disable the Close(x) icon script using java script . is there any event that can be used to prompt the user before closing the new window.
0
1055
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, how can i remove/disable the tray icon for the started Express Edition from the system tray. Te icon directs me to the express editons website after clicking on it. I dont want these tray icon. It will be shown for any Express Edition: C#,VB,VC++,... Thanks in advance,...
0
8356
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
8866
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
8781
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
8550
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
5663
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
4198
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
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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
1772
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.