Toolbox: How to handle Cancel
Chris Mahoney (1684) 2165 posts |
Hi all, I have a question about handling a “cancel” in a Toolbox app. I have a menu, and one of the options opens a new window (by using “show object”). That window has a few gadgets on it, mainly number ranges and option buttons. There is also a Cancel button, with the cancel flag set. When running the app (or when using it through ResTest), the menu item opens the window, the gadgets respond, and the Cancel button closes the window. However, if you then reopen the window from the menu, it retains any modifications. In other words, the Cancel button is hiding the window, but isn’t actually cancelling the changes. Am I missing something, or do I need to handle this manually through code? If so, is there a quick way to do it, or do I need to reset each gadget one by one? Thanks :) |
Colin (478) 2433 posts |
Cancel doesn’t change the window’s state you have to do that yourself. Have the window issue a Window_AboutToBeShownEvent when opening – the default event. You keep a record of the values that the window is used to change and on a Window_AboutToBeShownEvent you set the gadget values. When you press ok you modify your records from the window and if you press cancel you don’t. When you cancel with adjust you can reset the window values from the same function you used to set the values after the Window_AboutToBeShownEvent. |
Chris Mahoney (1684) 2165 posts |
OK, so I’m not missing anything after all. Thanks :) |