is there a way to disable the X button on a form?
Printable View
is there a way to disable the X button on a form?
In the Form_Closing routine of the Form you can add this in to disable the X button:
vb Code:
If e.CloseReason = CloseReason.UserClosing Then e.Cancel = True End If
this code disables all ways of closing the form all I want to disable is the X button and Alt+F4
If I add a button to the form and in its button click event for example I put:
Application.Exit
it closes just fine.
i dont want to add exit the application. I want to close a dialog form. so i use Me.Close() and this doesnt close
You might just have to set its visible property to false then instead of calling me.close.
Then call Application.Exit at the very end to close everything when done.
You can use an API or two to disable the 'x' close button which also removes the system menu item of Close.
http://www.vbforums.com/showpost.php...20&postcount=2
trust me to break it
http://img101.imageshack.us/img101/5485/93202018yp8.jpg
It's not broken, it's just warning that you haven't returned a value from it on expected paths.
Are you having trouble getting it to work or something?
You could just set the control box property to false......but then there would be no maximize or minimize buttons.
You could do that but then the rest of the controls/buttons will be removed too. If you only want the 'x' close button disabled then that wont work.
You can have the sub a Sub instead of a Function and that will remove the warning.