473,804 Members | 4,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable 'Close box' in upper right of form

It's easy to disable the Minimizebox and Maximizebox because they are
members of the form, but how do I disable the Closebox or whatever it
is called???
(Why are some things so hard to find out?) Why isn't there a "See Also"
topic for this. Why isn't there a named member for this?

Thank you,
dbuchanan

Nov 21 '05 #1
3 5130
Set the Form's "ControlBox " Property to False or you can trap the closing
from the control box by overriding the WndProc Method
<System.Securit y.Permissions.P ermissionSetAtt ribute(System.S ecurity.Permiss ions.SecurityAc tion.Demand, Name:="FullTrus t")> _
Protected Overrides Sub WndProc(ByRef m As Message)
Dim SC_Close As Integer = &HF060
Dim WM_SysCommand As Integer = &H112
Select Case m.Msg
Case &H112 'WM_SYSCOMMAND
' The WM_ACTIVATEAPP message occurs when the application
' becomes the active application or becomes inactive.
Select Case m.WParam.ToInt3 2
Case &HF060 'SC_Close 'User clicked on "X"
'Do something if you want then exit sub without
passing the Message on to MyBase...this will stop the form from firing the
close event
Exit Sub
End If
End Select
End Select
MyBase.WndProc( m)
End Sub
--
Dennis in Houston
"dbuchanan" wrote:
It's easy to disable the Minimizebox and Maximizebox because they are
members of the form, but how do I disable the Closebox or whatever it
is called???
(Why are some things so hard to find out?) Why isn't there a "See Also"
topic for this. Why isn't there a named member for this?

Thank you,
dbuchanan

Nov 21 '05 #2
Hi Dennis,

If I set the ControlBox to false then I lose the Minimizebox and the
Maximizebox, which I want to keep.

Thank you for sharing your work-around to the absence of a way to
disable or individually hide the closebox button. It achieves one goal
- not allowing the user to close the form using that button. But it
misses the other goal by still displaying as if it is an enabled
control.

I am disappointed that because Microsoft didn't give us control over
this we have to violate the Windows standard of displaying all controls
that don't work as 'disabled' or 'grayed out'.

--
dbuchanan

Nov 21 '05 #3
"dbuchanan" <db*********@ho tmail.com> schrieb:
It's easy to disable the Minimizebox and Maximizebox because they are
members of the form, but how do I disable the Closebox or whatever it
is called???


<URL:http://dotnet.mvps.org/dotnet/code/windowsandforms/#NoClose>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4

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

Similar topics

1
1791
by: Alleg | last post by:
hi everyone I am new to VC++.NET, however, I have to implement this project in vc++.net. Here is the trouble I am facing. I wanna disable the red close button at the right upper corner of a vc++.net form. How to do this? YOur help is greatly appreciated!
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...
5
11075
by: Stan Sainte-Rose | last post by:
Hi, Which event is called when the user click on the close window icon (X) ? I want, when he clicks on this icon, to display a message before closing the form. If he replys by No, I don't want to close the form. Thks for your help Stan
12
65493
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!
7
1677
by: eye5600 | last post by:
I have a procedure that creates a file, then generates a log report via Crystal. If the user closes the form after the file is created and before the log appears, the form closes, but (it appears that) a thread creating the Crystal report continues to run. How do I get hold of the thread and close it, or alternatley, look to see if it's running so I can delay close of the form?
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.
1
3872
by: dan.c.roth | last post by:
oForm.Close() vs this.Close() in a modal dialog. oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click event of the Form, does not. I can think of the reason for this but is this documented and if so can someone give me the reference. And is this true for .net 1 and 2. Thanks
5
2610
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing?
2
2370
by: mahesh123 | last post by:
Hi, I had a small problem regarding the Right click of the Mouse button. ie when the form as Border Style= Fixed style, Control Box = False. these are the properties set to the form. and the problem when we make the exe and run that form then click continously on the form at the task bar(right click) . then we find the pop menu with option close and minimise are enable and all are disable. Actual result is even though when we click...
0
9706
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
9579
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
10575
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...
1
10319
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
10076
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
9144
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
7616
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
6851
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();...
3
2990
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.