473,387 Members | 1,711 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,387 software developers and data experts.

[VB.Net] How to disable tthe "X" button on the top-right cornor?

Hello:

I currently use

Me.FormBorderStyle = FormBorderStyle.None

to hide the tile bar, but it looks quite ugly.

It's easy to disable the "X" button using VB6, but I really can't find out
any way to do the same thing using VB.Net.

Thanks!!
Nov 20 '05 #1
2 8322
Hello,

A quick solution is to set the Form's ControlBox property to False. This
will hide everything on the title bar except for the title itself. However,
this does not remove the Alt-F4 functionality.

Also, Herfried K. Wagner posted an idea in a previous thread: "I've put
e.Cancel = True in the Form_Closing event and the users can click the 'X'
all day long without closing the form."

(This comes from
http://groups.google.com/groups?hl=e....phx.gbl#link6 )

Here are a couple threads with examples of making the API call:

http://groups.google.com/groups?hl=e...close%2Bbutton

http://groups.google.com/groups?hl=e...close%2Bbutton

Take care,

Eric

"KKuser" <a.*@c.d.com> wrote in message
news:Oi*************@tk2msftngp13.phx.gbl...
Hello:

I currently use

Me.FormBorderStyle = FormBorderStyle.None

to hide the tile bar, but it looks quite ugly.

It's easy to disable the "X" button using VB6, but I really can't find out
any way to do the same thing using VB.Net.

Thanks!!

Nov 20 '05 #2
* "KKuser" <a.*@c.d.com> scripsit:
I currently use

Me.FormBorderStyle = FormBorderStyle.None

to hide the tile bar, but it looks quite ugly.
\\\
Private Declare Auto Function GetSystemMenu Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal bRevert As Int32 _
) As IntPtr

Private Declare Auto Function GetMenuItemCount Lib "user32.dll" ( _
ByVal hMenu As IntPtr _
) As Int32

Private Declare Auto Function DrawMenuBar Lib "user32.dll" ( _
ByVal hWnd As IntPtr _
) As Int32

Private Declare Auto Function RemoveMenu Lib "user32.dll" ( _
ByVal hMenu As IntPtr, _
ByVal nPosition As Int32, _
ByVal wFlags As Int32 _
) As Int32

Private Const MF_BYPOSITION As Int32 = &H400
Private Const MF_REMOVE As Int32 = &H1000

Private Sub RemoveCloseButton(ByVal frmForm As Form)
Dim hMenu As IntPtr, n As Int32
hMenu = GetSystemMenu(frmForm.Handle, 0)
If Not hMenu.Equals(IntPtr.Zero) Then
n = GetMenuItemCount(hMenu)
If n > 0 Then
RemoveMenu(hMenu, n - 1, MF_BYPOSITION Or MF_REMOVE)
RemoveMenu(hMenu, n - 2, MF_BYPOSITION Or MF_REMOVE)
DrawMenuBar(frmForm.Handle)
End If
End If
End Sub
///
It's easy to disable the "X" button using VB6


I doubt that this was possible in VB6. You were able to hide the
control box there which is possible in VB.NET too, but IMO that doesn't
make much sense.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

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

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
2
by: steve | last post by:
Hi, I need to do conditional script "include", but like to pull the code from db instead of a file. How do I do that? Reason: I like to implement some complex regex logic, and make it table...
1
by: Alex | last post by:
Sorry for the basic questions; just starting with ASP.NET I am using an HTML button to open another modeless dialog window: <INPUT style="FONT-WEIGHT: bold; Z-INDEX: 119; LEFT: 48px; WIDTH:...
0
by: **Developer** | last post by:
The code is to snap the mouse cursor to a given button but only if the user allows it. I've never read ControPanel values and wonder if there is a better way to get the info. The...
8
by: Ulysse | last post by:
Hello, I need to clean the string like this : string = """ bonne mentalit&eacute; mec!:) \n <br>bon pour info moi je suis un serial posteur arceleur dictateur ^^* \n ...
5
by: Maria Sudderman | last post by:
I have a prblem with the "onClick" command. onClick="insert('<a href="URI">', '</a>')"> but this is not correct! why? Maria
1
by: manchin2 | last post by:
Hi, Can anybody please provide the information about "&quot" and its use, if possible please provide an example. ...
4
by: thaytu888888 | last post by:
Here is my codes in aspx page: <td colspan="2" class="main_menu" runat="server" onclick='toggleDisplay(<%#Eval("description")%>);'><%#Eval("description")%></td> Here is in "View source": ...
1
by: Shaba99 | last post by:
Hey everyone, New to this forum, but i search for answers here often. I have a c# windows application which embeds windows media player on the form. The application (biz rule) requires that the...
0
by: Rajat Kumar | last post by:
I have a page in ASP.NET 2.0. I add a button in design view and the page runs fine. I then double-click the button to create the click method in the code. Then when I run the page I get the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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
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,...

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.