VB Form: Controlbox = False

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

    #1

    VB Form: Controlbox = False

    I can use the property of the Form to remove the "x" from the top of the
    form.

    Is there a way in VB to leave the X there but program something so you
    cannot close the form?

    Or like an ONCLOSE event that you can just put "cancel" ?

    If i remember correctly...bac k in vb 1.0 days or so there was a canclose on
    the form.

    Form1.canclose = False or something like that.

    Im looking thru msdn and all i found so far is the Controlbox Y/N


  • Jason

    #2
    Re: VB Form: Controlbox = False

    in the form closing event just type, e.cancel()

    "Miro" <mironagy@golde n.net> wrote in message
    news:u$EIjKxcGH A.4576@TK2MSFTN GP05.phx.gbl...[color=blue]
    >I can use the property of the Form to remove the "x" from the top of the
    >form.
    >
    > Is there a way in VB to leave the X there but program something so you
    > cannot close the form?
    >
    > Or like an ONCLOSE event that you can just put "cancel" ?
    >
    > If i remember correctly...bac k in vb 1.0 days or so there was a canclose
    > on the form.
    >
    > Form1.canclose = False or something like that.
    >
    > Im looking thru msdn and all i found so far is the Controlbox Y/N
    >[/color]


    Comment

    • gene kelley

      #3
      Re: VB Form: Controlbox = False

      On Mon, 8 May 2006 22:47:06 -0400, "Miro" <mironagy@golde n.net> wrote:
      [color=blue]
      >I can use the property of the Form to remove the "x" from the top of the
      >form.
      >
      >Is there a way in VB to leave the X there but program something so you
      >cannot close the form?
      >
      >Or like an ONCLOSE event that you can just put "cancel" ?
      >
      >If i remember correctly...bac k in vb 1.0 days or so there was a canclose on
      >the form.
      >
      >Form1.canclo se = False or something like that.
      >
      >Im looking thru msdn and all i found so far is the Controlbox Y/N
      >[/color]

      I think without exception, a user would fully expect the "X" button to
      close the form, otherwise, consider it a bug.

      What is the logic of a non-functioning "X" button?

      Gene

      Comment

      • gene kelley

        #4
        Re: VB Form: Controlbox = False

        On Mon, 8 May 2006 21:01:11 -0700, "Jason" <jshickam@comca st.net>
        wrote:
        [color=blue]
        >in the form closing event just type, e.cancel()
        >[/color]

        e.Cancel () by itself would prohibit the form from closing under any
        circumstance - would it not?

        Gene


        [color=blue]
        >"Miro" <mironagy@golde n.net> wrote in message
        >news:u$EIjKxcG HA.4576@TK2MSFT NGP05.phx.gbl.. .[color=green]
        >>I can use the property of the Form to remove the "x" from the top of the
        >>form.
        >>
        >> Is there a way in VB to leave the X there but program something so you
        >> cannot close the form?
        >>
        >> Or like an ONCLOSE event that you can just put "cancel" ?
        >>
        >> If i remember correctly...bac k in vb 1.0 days or so there was a canclose
        >> on the form.
        >>
        >> Form1.canclose = False or something like that.
        >>
        >> Im looking thru msdn and all i found so far is the Controlbox Y/N
        >>[/color]
        >[/color]

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: VB Form: Controlbox = False

          "Miro" <mironagy@golde n.net> schrieb:[color=blue]
          >I can use the property of the Form to remove the "x" from the top of the
          >form.
          >
          > Is there a way in VB to leave the X there but program something so you
          > cannot close the form?
          >
          > Or like an ONCLOSE event that you can just put "cancel" ?
          >
          > If i remember correctly...bac k in vb 1.0 days or so there was a canclose
          > on the form.
          >
          > Form1.canclose = False or something like that.[/color]


          Check out the form's '*Closing*' (and '*Closed*') events. Inside the event
          handler, set 'e.Cancel' to 'True'

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: VB Form: Controlbox = False

            Miro,

            In addition to Gene, without a message box telling that it is not closing
            and telling the reason why, this is considered as a bug in your program.

            Cor

            "Miro" <mironagy@golde n.net> schreef in bericht
            news:u$EIjKxcGH A.4576@TK2MSFTN GP05.phx.gbl...[color=blue]
            >I can use the property of the Form to remove the "x" from the top of the
            >form.
            >
            > Is there a way in VB to leave the X there but program something so you
            > cannot close the form?
            >
            > Or like an ONCLOSE event that you can just put "cancel" ?
            >
            > If i remember correctly...bac k in vb 1.0 days or so there was a canclose
            > on the form.
            >
            > Form1.canclose = False or something like that.
            >
            > Im looking thru msdn and all i found so far is the Controlbox Y/N
            >[/color]


            Comment

            • Dennis

              #7
              Re: VB Form: Controlbox = False

              Add this to your Form's Code and you can do whatever you want then the user
              clicks the "X":


              <System.Securit y.Permissions.P ermissionSetAtt ribute(System.S ecurity.Permiss ions.SecurityAc tion.Demand, Name:="FullTrus t")> _
              Protected Overrides Sub WndProc(ByRef m As Message)
              Dim SC_Close As Integer = &HF060
              Dim WM_SysCommand As Integer = &H112
              Select Case (m.Msg)
              ' The WM_ACTIVATEAPP message occurs when the application
              ' becomes the active application or becomes inactive.
              Case &H112 'WM_SYSCOMMAND
              Select Case m.WParam.ToInt3 2
              Case &HF060 'SC_Close 'User clicked on "X"
              'DO WHATEVER YOU WANT HERE
              Exit Sub
              End Select
              End Select
              MyBase.WndProc( m)
              End Sub

              --
              Dennis in Houston


              "Cor Ligthert [MVP]" wrote:
              [color=blue]
              > Miro,
              >
              > In addition to Gene, without a message box telling that it is not closing
              > and telling the reason why, this is considered as a bug in your program.
              >
              > Cor
              >
              > "Miro" <mironagy@golde n.net> schreef in bericht
              > news:u$EIjKxcGH A.4576@TK2MSFTN GP05.phx.gbl...[color=green]
              > >I can use the property of the Form to remove the "x" from the top of the
              > >form.
              > >
              > > Is there a way in VB to leave the X there but program something so you
              > > cannot close the form?
              > >
              > > Or like an ONCLOSE event that you can just put "cancel" ?
              > >
              > > If i remember correctly...bac k in vb 1.0 days or so there was a canclose
              > > on the form.
              > >
              > > Form1.canclose = False or something like that.
              > >
              > > Im looking thru msdn and all i found so far is the Controlbox Y/N
              > >[/color]
              >
              >
              >[/color]

              Comment

              • Miro

                #8
                Re: Solved - VB Form: Controlbox = False

                Thank you,

                I just couldnt figure out where vb.net is hiding all these events.

                You are correct, if there is a "X" box a user would expect it to close. I
                agree,

                I am trying to play with events and disable and enable things to find out
                where "everything is" in vb.net

                I just found out now how to access all the events on a form. I could never
                find them.

                I kept pulling up my "form" in my "CLASS NAME" drop down and looked for the
                events in the "METHODS" drop down there.
                I just now found the Base Class Events ... so i can now see all the events
                for the form.
                - I couldnt figure out how to access all the other events for the form.

                But going back to the original question, I was thinking of a form where the
                "X" is showing, but i only allow someone to close
                it if an event or something else isnt partially being worked on - that
                cannot be stopped 1/2 way thru.

                Thank you again,

                My basic questions - as basic as they seem, this one turned on a light with
                actually being able to find how to access all the events.

                Im slowely teaching myself vb.net and having a hard time adjusting to some
                things. Im use to using a pure "coder" where everything is written in text.

                Miro


                "Miro" <mironagy@golde n.net> wrote in message
                news:u$EIjKxcGH A.4576@TK2MSFTN GP05.phx.gbl...[color=blue]
                >I can use the property of the Form to remove the "x" from the top of the
                >form.
                >
                > Is there a way in VB to leave the X there but program something so you
                > cannot close the form?
                >
                > Or like an ONCLOSE event that you can just put "cancel" ?
                >
                > If i remember correctly...bac k in vb 1.0 days or so there was a canclose
                > on the form.
                >
                > Form1.canclose = False or something like that.
                >
                > Im looking thru msdn and all i found so far is the Controlbox Y/N
                >[/color]


                Comment

                Working...