|
-
Feb 15th, 2010, 05:59 AM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - Reload a form
it's possivel reload the actual form?
thanks
-
Feb 15th, 2010, 07:09 AM
#2
Re: [VB6] - Reload a form
It is possible to reload any form provided it is not already loaded.
What does "the actual form" mean?
-
Feb 15th, 2010, 07:56 AM
#3
Thread Starter
PowerPoster
Re: [VB6] - Reload a form
 Originally Posted by Hack
It is possible to reload any form provided it is not already loaded.
What does "the actual form" mean? 
i have 1 game. and i want a restart option. how can i reload the form(Level)?
(i can do it by object by object, but exist a diferent way?)
thanks
-
Feb 15th, 2010, 08:36 AM
#4
Re: [VB6] - Reload a form
This will unload the form...!
And this will show/load the Form:
... 
Or you can include those things that will be executed on starting the game inside a sub or function. Example:
Code:
Public Function StartGame()
'// Load sprites
'// Load Graphics
'// Load configuration, etc.
End Function
And another for unloading:
Code:
Public Function EndGame()
'// unLoad sprites
'// unLoad Graphics
'// unLoad configuration, etc.
End Function
So, when the user wants to restart the game, call EndGame and then call the StartGame....
It's just a thought...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 15th, 2010, 08:42 AM
#5
Re: [VB6] - Reload a form
I'm assuming you have all your code within secregated methods and not in your form events.
Thus you should be able to simply re-call the methods which initialize your game-screen, your variables and objects.
However, If you really must re-load the form you need to free the current form from memory first before you reload it:
VB Code:
Unload Form1 Set Form1 = Nothing Load Form1 Form1.Show
If you do not set the actual form to nothing the Form_Initialize() event will not be triggered a consecutive time.
If you are using a Form variable you still must set the actual form to nothing as well or you also get the problem of the Form_Initialize() event not firing again when reloading the form.
The reason for this is that VB's Unload removes the form or control from memory but not the actual code page. The form's code page still resides in memory untill you set the actual Form1 object to nothing.
Last edited by Optional; Feb 15th, 2010 at 07:12 PM.
Kind Regards,
Optional
If you feel this post has helped in answering your question please return the favour and Rate this post.
If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.
VB6 - (DataGrid) Get the Row selected with the right mouse button
-
Feb 15th, 2010, 08:55 AM
#6
Thread Starter
PowerPoster
Re: [VB6] - Reload a form
 Originally Posted by Optional
I'm assuming you have all your code within secregated methods and not in your form events.
Thus you should be able to simply re-call the methods which initialize your game-screen, your variables and objects.
However, If you really must re-load the form you need to free the current form from memory first before you reload it:
VB Code:
Unload Form1
Set Form1 = Nothing
Load Form1
Form1.Show
If you do not set the actual form to nothing the Form_Initialize() event will not be triggered a consecutive time.
If you are using a Form variable you still must set the actual form to nothing as well or you also get the problem of the Form_Initialize() event not firing again when reloading the form.
The reason for this is that VB's Unload removes the form or control from memory but not the actual code page. The form's code page still resides in memory untill you set the actual Form1 object to nothing.
Edit: As usual akhileshbc, you beat me to it and as usual with a much clearer response 
in these case i can't use unload, because i can't unload the form that i'm using .
but is slow, is like pause the program(in these case the game), then load the form.
what you can tell me?
akhileshbc, i like you sugestion, i build 1 similar situation. but instead work with every controls(it's a diferent way that i build a game ), i wanted do these not so "complex"
thanks
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
|