473,654 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disable Close button (X)

Sam
Hi,
I've seen a large number of posts about this subject, and one answer
everyone seems to be happy with is the following:

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

However I must say, it does NOT work with my environement (Framework
2.0, IDE : VBExpress). What I get is a close button being offset to the
right, so it is almost visible but not quite. I'm still able to click
on a part of it and close the form.
Am I the only one in this situation ?

Thanks

Jan 23 '06 #1
8 5477
Using VS2005 and .NET 2.0, I disable the close button (Control Box)
with:

MyForm.ControlB ox = False

Jan 23 '06 #2
Sam
Thanks for the reply. However I do not want to use this property, as I
want to keep the maximise and minimise button. Sorry I should have
mention this in my first post.

Jan 23 '06 #3
"Sam" <sa************ *@googlemail.co m> schrieb:
I've seen a large number of posts about this subject, and one answer
everyone seems to be happy with is the following:

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

However I must say, it does NOT work with my environement (Framework
2.0, IDE : VBExpress).


The code works just fine on .NET 2.0, VS 2005 Professional, Windows XP SP2,
Visual Styles enabled.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 23 '06 #4
Sam
Herfried,

I believe you, but I swear, in my case, it does not work ;)
see the picture:

http://graphicsxp.free.fr/formclose.JPG

I can still highlight the close button at the very right of the child
form and click on it.
Can you help ?

Jan 23 '06 #5
"Sam" <sa************ *@googlemail.co m> schrieb:
I believe you, but I swear, in my case, it does not work ;)
see the picture:


Well, you forgot to say that you are talking about an MDI child form.
Sorry, I do not know a solution for the problem.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 23 '06 #6
Sam
Sorry I forgot to mention that indeed :(

anyone knows?

Thanks anyway

Jan 23 '06 #7
Sam wrote:
Sorry I forgot to mention that indeed :(
anyone knows?


I did this in VB6 using some API calls. The VB.NET equivalent is as follows:
\\\
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenu A" _
(ByVal hMenu As Integer, ByVal nPosition As Integer, _
ByVal wFlags As Integer, ByVal wIDNewItem As Integer, _
ByVal lpString As String) As Integer
Private Declare Function GetMenuItemID Lib "user32" _
(ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Private Const MF_GRAYED As Integer = &H1
Private Const MF_BYCOMMAND As Integer = &H0

[...]

Private Sub MDIChildForm_Lo ad(ByVal sender As Object, _
ByVal e As System.EventArg s) Handles Me.Load

'Disable the Close button on load
Dim hMenu As Integer
Dim hItem As Integer

hMenu = GetSystemMenu(M e.Handle.ToInt3 2, 0)
hItem = GetMenuItemID(h Menu, 6)
ModifyMenu(hMen u, hItem, MF_BYCOMMAND Or MF_GRAYED, -9, "&Close")

End Sub
///

There may be a better way to do this, but if so, I don't know what it is.

--

(O)enone
Jan 23 '06 #8
Sam
thanks but i must be damned... :(
it gives me the exact same behaviour as described above with the link
to my screenshot...
I really don't know why I get this.

Jan 23 '06 #9

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.
3
6131
by: Saurabh Sharma | last post by:
Hi How do i disable windows close button in forms in C# Regards Saurabh
6
2795
by: Raghu Raman | last post by:
Hi, we are doing an in house project in c#.net(asp.net).We wanted to close our application when ever the user presses the SIGNOUT button. Even though we programtically disconnects them from the database,when we press the Internet explorers Back button ,all the browsed pages are displayed with the data**. 1.could you pls tell me how to disable the back-button of IE
3
2597
by: Paul | last post by:
Hi, just wondering if there is a way to disable the back button of the browser as I have a logoff page and would like to not allow the back operation? Guessing there may be a way to do it through java script. -- Paul G Software engineer.
24
4853
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
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!
4
3505
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. ...
1
1676
by: jamesdel | last post by:
Hi I know how to disable the close button of the main access window. But i am not able to disable the maximum button. Can anyone help me in this regard. It certainly needs API function calling procedure. So anybody who is good in API can help me. I have disable the close button through this. But when i am trying to disable the maximum button using this same technique i am not getting the correct result. John
1
2311
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
2486
by: jagan1976 | last post by:
I want to disable close button for each report and it would apply to all users. Is there any script or method available which will disable close button for all reports at once without using properties. Please let me know the ideas to do. It would be better if the close button of all reports are disabled globally (if common propertity or script available) Thanks in advance, Jagan
0
8375
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
8290
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
8815
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
8593
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
7306
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
6161
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
4149
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...
1
2714
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
1593
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.