Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

X The close or end button 1

Status
Not open for further replies.

Dapper

Programmer
Nov 2, 2003
74
0
0
GB
How do you disable it.

Whats it called in vb... there the maxbutton and a minbutton,

I know it would be some thing like
nameofbutton(closebuttom).disabled = true

thanks
 
In the form_QueryUnload sub, place:

Cancel = 1

When the user clicks on the X, the unload action will be cancelled.

BB
 
Superb, yet so simple

thanks

I better give you a star.
 
There is a certain point of view that would suggest that this isn't the best solution...

for example, you can never neatly exit the application with the above code.

There is a better soution that will grey out the x button, which also resolves the other main objection that the above code doesn't conform with what users expect.

If you do a search on "GetSystemMenu" you will very quickly come up witha whole stack of answers and arguments for& against each method!



Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I must confess that I have never seen the logic in disabling the X. Put any cleanup code needed in either the form unload event or form terminate event depending on what you are trying to clean up.

The code will fire when the user clicks the X or whatever else you are using to close. (close button, code from another form etc, etc)

App works the way the user expects.

Please note, I do not wish to insult end users, but many have little concept of using an app. They expect things to work one way and get "upset" when things do not work that way.

Our job is to develop apps that they can and will use.



Terry (cyberbiker)
 
cyberbiker

I think we agree!

What I mean is that if a user encounters a command button that is ungreyed (enabled to you, me and other programmers) they expect "it" to do something if they click it and vice versa. Therefore to have a button that does nothing when enabled is confusing!

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Matt on that we do agree.

Having read many of your answers, I know you are much more expert than I.

And we may be on the same wave length about the desireability of disabling the X button

Users expect to be able to close a form using that button.

The only use I can gather from disabling the X button is to make certain clean up code fires.

This can be accomplished by placeing the cleanup code in either the form unload event (for most code, probably the best way) or in the form terminate event(necessary for some code such as setting a minimized form to maximized when the current form is closed Try it in the Unload event see why)

I feel that it is better to handle the cleanup without disabling the X.

Now if somebody would show me that I am wrong, I would greatly appreciate it since I learn by my mistakes (I guess that is why I am so smart. I make a lot of mistakes. think about it)


Terry (cyberbiker)
 
To keep the standard Windows interface, either disable the control, or remove all three by setting the form's ControlBox property to False

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top