Google Skupine ne podpirajo več novih objav ali naročnin v storitvi Usenet. Zgodovinsko vsebino si je še vedno mogoče ogledati.
Dismiss

Disabling/Enabling close button on a form

1 ogled
Preskoči na prvo neprebrano sporočilo

Marco Castro

neprebran,
18. dec. 2003, 15:19:4318. 12. 03
do
How can I disable and then re-enable the close button on a form? Thanks.


Armin Zingler

neprebran,
18. dec. 2003, 15:26:2418. 12. 03
do
"Marco Castro" <marco_do...@benlan.com> schrieb

> How can I disable and then re-enable the close button on a form?
> Thanks.

Set the enabled property.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Herfried K. Wagner [MVP]

neprebran,
18. dec. 2003, 17:08:3218. 12. 03
do
* "Marco Castro" <marco_do...@benlan.com> scripsit:

> How can I disable and then re-enable the close button on a form? Thanks.

Set its 'Enabled' property...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Armin Zingler

neprebran,
18. dec. 2003, 17:19:0818. 12. 03
do
"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> schrieb
> Set its 'Enabled' property...

*grrrrrrr*

Herfried K. Wagner [MVP]

neprebran,
18. dec. 2003, 18:09:0818. 12. 03
do
* "Armin Zingler" <az.n...@freenet.de> scripsit:

>> Set its 'Enabled' property...
>
> *grrrrrrr*

Sorry...

Cor

neprebran,
19. dec. 2003, 03:11:5119. 12. 03
do
Hi Marco,

If you mean the default close X than you can set the controlbox from the
form to false,
you disable than also the posibility to minimize and maximize.
I did not see something as minimize = false if you are looking for that.

I hope this helps?

Cor
..

Herfried K. Wagner [MVP]

neprebran,
19. dec. 2003, 07:38:3919. 12. 03
do
* "Cor" <n...@non.com> scripsit:

> If you mean the default close X than you can set the controlbox from the
> form to false,
> you disable than also the posibility to minimize and maximize.
> I did not see something as minimize = false if you are looking for that.

It's even possible to /disable/ the button, but I don't know how to
enable it:

\\\
Private Declare Function GetSystemMenu Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal bRevert As Int32 _
) As IntPtr

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

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

Private Declare 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
///

DaveJG

neprebran,
8. jan. 2004, 18:31:268. 1. 04
do
Below is some code I found in a different thread. Doesn't disable the
close-x, but simulates the VB6 queryunload unloadmode parameter.

Gary,

The code below effectively disables a form's close button.

HTH.

Danny L. Joe

----------------------------------
Private CloseButtonClicked As Boolean = False

Private Sub MyForm_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Me.CloseButtonClicked = True Then
Me.CloseButtonClicked = False 'reset close button detector
e.Cancel = True
Return
End If
End Sub

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then
Me.CloseButtonClicked = True
End If
MyBase.WndProc(m)
End Sub

0 novih sporočil