June 02, 2008

Open-Form and the Exit-Strategy (2)

Sometimes you use your source-codes since years and think - there is no easier, better and smarter way to do something, like the way in that piece of code.

So here. After writing and testing my last post everything runs well!

Today I refactored some parts of my exit-strategy code and created this much easier solution (normally this is not the goal of refactoring !):

all you need is a

KEY-EXIT in the startform:

EXIT_FORM (no_validate);

and a WHEN-FORM-NAVIGATE in all other forms

EXIT_FORM (no_validate);

Now we have a chain reaction, when exiting the startform. Each closing form will let the focus jump to another open form. Then the WHEN-FORM-NAVIGATE triggers and closes this form too. Because the global variable was set to AUTOCLOSE = TRUE.

After the last form the whole application is closed and that's the best way to close an entire application.

If some of those forms started other forms through call_form, then you have to use the WHEN-WINDOW-ACTIVATED, because the WHEN-FORM-NAVIGATE won't trigger while getting the focus.

Isn't that a really easy solution?
Have fun with it

No comments: