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
Printable View
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
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
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 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?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?Quote:
Originally Posted by jmcilhinney
EDIT: I know that specific one won't work, but is there anything along those lines?
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.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!Quote:
Originally Posted by jmcilhinney
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Would it be:Code:Private Sub Form1_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.What??
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.
Got it, thanks a lot!