Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Close down

Close down

Scheduled Pinned Locked Moved Visual Basic
helpquestion
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    twsted f8
    wrote on last edited by
    #1

    Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.

    V T G T 4 Replies Last reply
    0
    • T twsted f8

      Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      hi twsted f8 to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone. but Now if you set the Controlbox to false then you will not see the (X) button to close your Form, you will just have to create your own button. you can but the same code in the Following events The Following code is in your Form closing event Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub Note that you can Create a button for your self and write the same code. Hope this helps Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

      T 1 Reply Last reply
      0
      • T twsted f8

        Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.

        T Offline
        T Offline
        Tom Deketelaere
        wrote on last edited by
        #3

        twsted f8 wrote:

        I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called?

        look at the formborderstyle property there are several wich will do what you want all with different looks

        twsted f8 wrote:

        I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property?

        events: formclosing formclosed whith e.CloseReason=CloseReason.UserClosing you can distinguish between a user closing you'r form or another programme (or you'r own programme) hope this helps

        If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

        S 1 Reply Last reply
        0
        • V Vimalsoft Pty Ltd

          hi twsted f8 to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone. but Now if you set the Controlbox to false then you will not see the (X) button to close your Form, you will just have to create your own button. you can but the same code in the Following events The Following code is in your Form closing event Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub Note that you can Create a button for your self and write the same code. Hope this helps Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

          T Offline
          T Offline
          Tom Deketelaere
          wrote on last edited by
          #4

          Vuyiswamb wrote:

          Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Dispose() Else '''Do nothing End If End Sub

          now in both cases the form will close instead of '''do nothing there should be e.cancel = true

          Vuyiswamb wrote:

          to Remove the button to Maximise, Right Click on your Form and click on Properties, in your Properties Window, look for Window Style --> You will find the Option "ControlBox", set it to "False" and you Buttons will be gone

          the user is still able to maximise his window by dubbleclicking the title bar using the formborderstyle property might be a better way to accomplish what he wants

          If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

          1 Reply Last reply
          0
          • T twsted f8

            Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.

            G Offline
            G Offline
            GuyThiebaut
            wrote on last edited by
            #5

            Just an idea - why not allow the users to maximize the form and anchor objects on the form. This will then rescale the form as the user resizes it. I mention this just in case you have not yet figured out how to allow the form to rescale - and in case that is what you were trying to prevent. Apologies if I am teaching my grandmother to suck eggs here... Regards Guy

            You always pass failure on the way to success.
            1 Reply Last reply
            0
            • T Tom Deketelaere

              twsted f8 wrote:

              I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called?

              look at the formborderstyle property there are several wich will do what you want all with different looks

              twsted f8 wrote:

              I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property?

              events: formclosing formclosed whith e.CloseReason=CloseReason.UserClosing you can distinguish between a user closing you'r form or another programme (or you'r own programme) hope this helps

              If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

              S Offline
              S Offline
              Salman Sheikh
              wrote on last edited by
              #6

              the best i found to let my form remain in maximized state is by overriding onSizeChanged method (or by handling sizechanged event) and writing following lines there If Not DesignMode Then If Not Me.WindowState = FormWindowState.Maximized Then Me.WindowState = FormWindowState.Maximized End If End If if user tries to change the size even by clicking on maximize button the form will restore back to previous stat. keep in mind initially you will have to set the windowstate of form to Maximized

              Salman Sheikh

              T 1 Reply Last reply
              0
              • S Salman Sheikh

                the best i found to let my form remain in maximized state is by overriding onSizeChanged method (or by handling sizechanged event) and writing following lines there If Not DesignMode Then If Not Me.WindowState = FormWindowState.Maximized Then Me.WindowState = FormWindowState.Maximized End If End If if user tries to change the size even by clicking on maximize button the form will restore back to previous stat. keep in mind initially you will have to set the windowstate of form to Maximized

                Salman Sheikh

                T Offline
                T Offline
                Tom Deketelaere
                wrote on last edited by
                #7

                true this will work nice if you want the form to be maximised but the OP asked to prevent maximising so I figured the form isn't maximised at all (also not at start). you can still use you're code to accomplish this (just put the size back to original size) but the user will get the arrows for resising the window, will be able to click and drag, might even be able to resize the window for a split second. All of this will result in a very confused user and a flickering screen so... but if you want the windowstate to be maximised at all times you'r code would work, although I think the window will flicker for a split second (not shure about this)

                If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

                1 Reply Last reply
                0
                • T twsted f8

                  Hi everyone Could anyone help me. I would like to restrict the users of my software from maximise the form. Is there any way of disabling the form maximise property? The other thing is I would also like to detect when the user closes the form using the X in the right corner.I would like to ask the user if they want to save before closing down. What event is this and how is it called? Thanks for reading this and I hope u will be able to help me.

                  T Offline
                  T Offline
                  Taylor Kobani
                  wrote on last edited by
                  #8

                  i think we have a property called Cancel in the event of form_close so you have to do this to prevent closing window

                  e.cancel=true

                  A.E.K

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups