Application Control Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laszlo Szijarto

    #1

    Application Control Question

    I have an app which moves around between a series of forms. I don't want to
    keep the forms open but hidden. I need to close them as I switch back and
    forth from one form to another.

    Unfortunately, if I start up my app with Application.Run (new formLogin()),
    for example, as soon as the formLogin gets closed, the whole app exits.
    Yet, if I start up as follows:

    (new formLogin()).Sh ow();
    Application.Run ();

    if someone closes a form using the "X" (close) button, the App hangs out
    there in memory. Now, if someone hits the "X" button, I want to call
    Application.Exi t(). But the Closing and Closed events get called even if I
    call this.Close(), and I don't know of any way to differentiate whether the
    app was closed by the "X" button or a call to this.Close(). When it's done
    via this.Close(), I want to close only the current form and not the entire
    app. When it's done via the "X" button, I want to call Application.Exi t().

    So far, the only way I've been able to accomplish this is to create a class
    member called boolKillApplica tion, set to true by default. If I call
    this.Close() in my code, I set boolKillApplica tion = false. In the Closed
    event, then, I call Application.Exi t() if boolKillApplica tion.

    I know this is just a workaround.

    Can anyone suggest the RIGHT way to do this?

    Thank you,
    Laszlo


Working...