# VB 6 disable close button



## lamstaldy (Dec 16, 2001)

Is there any way to disable the close button in the control box, but leave the min and max buttons available? Or do I have to disable the control box and add my own min and max command buttons?


----------



## lamstaldy (Dec 16, 2001)

Never mind. I added my own minimize button, and then clicking the app in the tool bar maximizes it. Problem solved.


----------



## cassamine (Nov 22, 2002)

But still can anybody suggest a method to disable that X button, it convenient than makiing own minimize and max buttons.

cassamine


----------



## AbvAvgUser (Oct 3, 2002)

You can't disable it, but can surely control it through a few lines of code.

A couple of Boolean variables and a command button with some code in Form_unload will do the trick of throwing up an error message everytime someone tried to close your window through the X button on top. You can see to it that the window gets closed only through your command button


----------



## Mosaic1 (Aug 17, 2001)

Here's some code. But you can still close the Window using ALT + F4

From:
http://vbhelp.info/kb/kb0070004.asp



> Disable the close button from a form
> Disable the Close button on any form in your project with this handy code snippet!
> 
> First of all, you will need to add a module to your project. (Project->Add Module).
> ...


----------

