|
-
Apr 13th, 2007, 11:39 PM
#1
Thread Starter
Lively Member
[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.
-
Apr 13th, 2007, 11:42 PM
#2
Frenzied Member
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
-
Apr 13th, 2007, 11:43 PM
#3
Thread Starter
Lively Member
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.
-
Apr 14th, 2007, 03:52 AM
#4
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.
-
Apr 14th, 2007, 09:41 AM
#5
Thread Starter
Lively Member
Re: [2005] Respawning a form...
 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.
-
Apr 14th, 2007, 09:44 AM
#6
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.
-
Apr 14th, 2007, 09:46 AM
#7
Thread Starter
Lively Member
Re: [2005] Respawning a form...
 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.
-
Apr 14th, 2007, 09:56 AM
#8
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.
-
Apr 14th, 2007, 09:58 AM
#9
Thread Starter
Lively Member
Re: [2005] Respawning a form...
 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.
-
Apr 14th, 2007, 10:00 AM
#10
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.
-
Apr 14th, 2007, 10:03 AM
#11
Thread Starter
Lively Member
Re: [2005] Respawning a form...
 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.
-
Apr 14th, 2007, 10:09 AM
#12
Thread Starter
Lively Member
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.
-
Apr 14th, 2007, 10:10 AM
#13
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.
-
Apr 14th, 2007, 10:16 AM
#14
Thread Starter
Lively Member
Re: [2005] Respawning a form...
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|