Results 1 to 14 of 14

Thread: [RESOLVED] [2005] Respawning a form...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Resolved [RESOLVED] [2005] Respawning a form...

    Hello, how can you relaunch a form after it's closed? What event handle is nessecary, an what code will I need? Thanks!

    Regards,
    Silencer
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  2. #2
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] Respawning a form...

    Is it like.. the only form? Will the whole application close? Anyways, on the form closing event you should be able to just create a new instance of it and just re run it. I think.. w/e I'm going to bed.

    Good night vbforums

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Yes, its a one form application, and I want it to reload everytime it is closed, via taskmanager or not. The only way to kill it is enter a password, or terminate the process. Good night.
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Respawning a form...

    There is no way to "respawn" a form. One it's closed it loses it's window handle so it's not a window anymore. Also, if the user ends your process via the Task Manager then there is no process running to create any forms at all.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Quote Originally Posted by jmcilhinney
    There is no way to "respawn" a form. One it's closed it loses it's window handle so it's not a window anymore. Also, if the user ends your process via the Task Manager then there is no process running to create any forms at all.
    I know if the process is terminated its gone, but is it possible to tell the program as its loading that when it closes it reopens again?
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Respawning a form...

    You could handle the FormClosed event of your main form and call Process.Start to start a new instance but there's no guarantee that that code will be executed. Once a process is terminated it cannot do anything, so you would have to start the new instance before the existing instance closed. If the user terminates your process forcibly you may not get that chance.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Quote Originally Posted by jmcilhinney
    You could handle the FormClosed event of your main form and call Process.Start to start a new instance but there's no guarantee that that code will be executed. Once a process is terminated it cannot do anything, so you would have to start the new instance before the existing instance closed. If the user terminates your process forcibly you may not get that chance.
    Can it be in the form load event, and make it an If Then statement, like If Me.Close Then Process.Start?

    EDIT: I know that specific one won't work, but is there anything along those lines?
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Respawning a form...

    Think of it this way. If I was to say to you "before you die I want you to clap three times". Now someone walks up and shoots you in the back of the head. Will you clap? No you won't, because you can't. You knew you were supposed to and yet you can't. Now, even if your process knows that it is supposed start a new instance of itself before it exits, if it is killed then it will never get the chance to do so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Quote Originally Posted by jmcilhinney
    Think of it this way. If I was to say to you "before you die I want you to clap three times". Now someone walks up and shoots you in the back of the head. Will you clap? No you won't, because you can't. You knew you were supposed to and yet you can't. Now, even if your process knows that it is supposed start a new instance of itself before it exits, if it is killed then it will never get the chance to do so.
    Yes, but as I said earlier, I know it won't be able to do anything if it is terminated, I'm solely talking about if someone presses alt+f4, or end task, if the process is terminated, there is no chance of anything happening, unless its a virus cooked up by some genius hacker.
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Respawning a form...

    Then call Application.Restart in the FormClosed event of the main form, or maybe Process.Start in the Shutdown event of the application.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Quote Originally Posted by jmcilhinney
    Then call Application.Restart in the FormClosed event of the main form, or maybe Process.Start in the Shutdown event of the application.
    That should work, but I don't have a shutdownevent or formclosed event, what would it be, like I know this is the load, but what would the code be for the shutdownevent and formclosed event...thank you!

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Would it be:
    Code:
    Private Sub Form1_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.What??
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Respawning a form...

    You get the IDE to generate event handlers for you. For the default events of controls and components, like Form.Load, that can be done by double-clicking in the designer. For non-default events of controls or components you can double-click the desired event in the Properties window to generate an event handler. For absolutely any event at all you can use the drop-down lists above the code window.

    You can open the form's code window and create a FormClosed event handler with the drop-down lists at the top. For application events, like Shutdown, you have to open the code file using the button on the Application tab of the project properties.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    NYC
    Posts
    86

    Re: [2005] Respawning a form...

    Got it, thanks a lot!
    There is a thin line between hobby, and obsession.

    If you found my post helpful, please rate it.
    My Laptop System Stats: nVidia 8800 graphics card, Two Intel Core Duo processors, 3.5 GB RAM, Windows Vista Ultimate, 15.4 Widescreen Brightview display, Built-in Webcam and Microphone.
    My Alienware System Stats: nVidia 8800 graphics card, Intel Core Duo Extreme Edition processors, 4 gb RAM, Windows Vista Ultimate, 21 Inch Plasma Display, 42 Inch LCD HD display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width