Disable the Control Box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Wright

    Disable the Control Box

    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


  • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

    #2
    RE: Disable the Control Box

    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


    "John Wright" wrote:
    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
    >
    >
    >

    Comment

    • kimiraikkonen

      #3
      Re: Disable the Control Box

      On Jul 10, 8:56 pm, "John Wright" <riley_wri...@h otmail.comwrote :
      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
      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_BUTT ON As Integer = 512

      Protected Overrides ReadOnly Property CreateParams() As
      System.Windows. Forms.CreatePar ams
      Get
      Dim noclose As CreateParams
      noclose = MyBase.CreatePa rams
      noclose.ClassSt yle = CP_NOCLOSE_BUTT ON
      Return noclose
      End Get
      End Property

      ' Codes...

      End Class

      ' ----End-----

      Hope this helps,

      Onur Güzel


      Comment

      Working...