|
|
 |
|
|
 |
|
|
|
|
 |
Nov
28
Written by:
slhilbert
11/28/2005 10:08 PM
The below information is copied and pasted from this link, http://www.dotnet4all.com/dotnet-code/2004/12/vbnet-how-to-disable-tthe-x-button-on.html.
It is being pasted here in case that link ever goes dead.
Found the following interesting discussion in the Newsgroups:
[VB.Net] How to disable tthe "X" button on the top-right cornor? by:KKuser
|
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!!
|
| |
Reply: by:Eric Lemmon
|
| |
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=en&lr=&ie=UTF-8&frame=right&th=a92bcda2ff0b1eb7&seekm=emp%24d%23C3CHA.1808%40TK2MSFTNGP11.phx.gbl#link6 )
Here are a couple threads with examples of making the API call:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=OPk5VkwlCHA.1492%40tkmsftngp02&rnum=1&prev=/groups%3Fsourceid%3Dnavclient%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Ddotnet%2Bdisable%2Bclose%2Bbutton
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=OSbScTZPCHA.2524%40tkmsftngp10&rnum=2&prev=/groups%3Fsourceid%3Dnavclient%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Ddotnet%2Bdisable%2Bclose%2Bbutton
Take care,
Eric
|
| |
Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
|
| |
\\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]
|
Tags:
1 comment(s) so far...
Re: Hiding the X button on a form in VB.NET
Hello, I have a different question. Can I use the red X button somewhere else - e.g. on a form as a normal button?
if someone knows how, wirte at: bufer24@azet.sk
By Anonymous on
7/7/2006 10:53 AM
|
|
|
For years of ramblings check out the "Blogchive" on the upper right.
|
 |
|