Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disable the Control Box

10 views
Skip to first unread message

John Wright

unread,
Jul 10, 2008, 1:56:23 PM7/10/08
to
Is there a setting on the form I can set to hide or disable the close button
(The Red "X" in the top right of an XP form) so the users cannot exit the
program, but still show the min and max buttons. The problem I have is on
some of the tabs in my program I have validation events on textboxes. When
the users clicks the "X" to close the program, the validation event fires
before exiting the program causing some confusion. Thanks.

John


Kerry Moorman

unread,
Jul 10, 2008, 2:52:03 PM7/10/08
to
John,

If you don't want the validation events to prevent the form from closing
then in the form's FormClosing event use:

e.Cancel = False

Kerry Moorman

kimiraikkonen

unread,
Jul 10, 2008, 4:20:29 PM7/10/08
to

If i recall correctly this has been discussed before, you need to use
that code in your form:

' ----Begin----

Public Class Form1

Private Const CP_NOCLOSE_BUTTON As Integer = 512

Protected Overrides ReadOnly Property CreateParams() As
System.Windows.Forms.CreateParams
Get
Dim noclose As CreateParams
noclose = MyBase.CreateParams
noclose.ClassStyle = CP_NOCLOSE_BUTTON
Return noclose
End Get
End Property

' Codes...

End Class

' ----End-----

Hope this helps,

Onur Güzel


0 new messages