powdarrmonkey Posted February 5, 2010 Posted February 5, 2010 ||. You want the form to close on either condition.
LosOjos Posted February 5, 2010 Posted February 5, 2010 This is the desired behaviour. I thought the desired behaviour was to only close the form if the cancel button was enabled (if it was a user requested close) err. confused - && or || ? If I'm right, use && Using || as powdarrmonkey suggests will indeed close the form either way, meaning an alt + F4 will also close it (regardless of whether the cancel button is enabled)
Gatt Posted February 5, 2010 Author Posted February 5, 2010 @Josh - the idea is that when the form loads the button is disabled - foricng the user to read whats on screen They can only close the app once the button has been enabled - until then the application cannot be allowed to close...
powdarrmonkey Posted February 5, 2010 Posted February 5, 2010 I thought the desired behaviour was to only close the form if the cancel button was enabled (if it was a user requested close) No, read the braced section of the if statement. The test is whether to cancel the close action or not, and you want to do this if either - the button was enabled and has been pressed - the form is being closed because the OS needs it to, not because the user asked for it to
LosOjos Posted February 5, 2010 Posted February 5, 2010 No, read the braced section of the if statement. The test is whether to cancel the close action or not, and you want to do this if either - the button was enabled and has been pressed - the form is being closed because the OS needs it to, not because the user asked for it to OK maybe I'm misunderstanding, but e.CloseReason == CloseReason.UserClose is true if the user has tried to close the form, not the OS, isn't it?
powdarrmonkey Posted February 5, 2010 Posted February 5, 2010 OK maybe I'm misunderstanding, but e.CloseReason == CloseReason.UserClose is true if the user has tried to close the form, not the OS, isn't it? Ye-es... and then if this is the case, we cancel the pending close message. Otherwise there was some other reason for closing it (e.g. the machine is shutting down) and we just keep quiet and let it.
LosOjos Posted February 5, 2010 Posted February 5, 2010 Ye-es... and then if this is the case, we cancel the pending close message. But then !btnClose.Enabled is true if the button is disabled, so we're allowing the form to be closed by the user when the button is still disabled...
Gatt Posted February 5, 2010 Author Posted February 5, 2010 But then !btnClose.Enabled is true if the button is disabled, so we're allowing the form to be closed by the user when the button is still disabled... IIRC - If windows is shutting down, and the app wont close properly, it will "End Task" it anyway so even if the button is disabled - the app will still closeas its an OS call. I think!
powdarrmonkey Posted February 5, 2010 Posted February 5, 2010 But then !btnClose.Enabled is true if the button is disabled, Ye-es, in which case we cancel the close request because the user shouldn't be able to close it yet... so we're allowing the form to be closed by the user when the button is still disabled... Not so. We are cancelling the user's request to close it if the button is still disabled.
LosOjos Posted February 5, 2010 Posted February 5, 2010 Got it! @powdarrmonkey, sorry I doubted you @Gatt, sorry for confusing things!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now