ReLoad Form Problem
-
I am working on a small game , and i have a problem -- when the user win a message box appear asking him if he want to play again if he answered -yes- the form must be shown again as it was in the beginning of the game , and i do not know how to reload the form :confused: thanks , Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
I am working on a small game , and i have a problem -- when the user win a message box appear asking him if he want to play again if he answered -yes- the form must be shown again as it was in the beginning of the game , and i do not know how to reload the form :confused: thanks , Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
Hi, AFAIK you can load a form only once. But you can show and hide it many times using either Show()/Hide() methods or setting Visible property true/false. Apart from that, you could create a new instance of your form, which would give you its initial state automatically (wanted or not). :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
I am working on a small game , and i have a problem -- when the user win a message box appear asking him if he want to play again if he answered -yes- the form must be shown again as it was in the beginning of the game , and i do not know how to reload the form :confused: thanks , Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
:rose:Hi Mona, you do one thing..... Create one function which loads the form and then recall it . example--------- MessageBox.Show("Are you want to play Again??????","Play Game",MessageBoxButtons.YesNo)==DialogResult.Yes) { ///call the functio here........... } Nisar Inamdar
-
:rose:Hi Mona, you do one thing..... Create one function which loads the form and then recall it . example--------- MessageBox.Show("Are you want to play Again??????","Play Game",MessageBoxButtons.YesNo)==DialogResult.Yes) { ///call the functio here........... } Nisar Inamdar
thank you Nisar Inamdar for your replay . i do a method witch create an instant from the form and call it and hide the current form ,and it works . but i have a question when i hide the current form every time the user win or lose the form still exists ,do you think that is over load in memory , and bad performance , i do not know i am asking thanks again for your Useful Replay :) Mona ,
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
Hi, AFAIK you can load a form only once. But you can show and hide it many times using either Show()/Hide() methods or setting Visible property true/false. Apart from that, you could create a new instance of your form, which would give you its initial state automatically (wanted or not). :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
thank you Luc Pattyn for your replay I do an instance in a method and hide the current form ,and it works , but i think when i hide the current form to call the new instance that i make an over load in memory because the current form is still exists . what do you think , How can i close the current form to cal its new instance ?? thanks again :) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
thank you Luc Pattyn for your replay I do an instance in a method and hide the current form ,and it works , but i think when i hide the current form to call the new instance that i make an over load in memory because the current form is still exists . what do you think , How can i close the current form to cal its new instance ?? thanks again :) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
why would you do that ? it is one or the other: 1. create a single instance, and now loop {initialize variables, show, hide} until app exits OR 2. loop {create an instance, show, close } until app exits it does not make sense to create a new instance, while a previous one is still around (hidden instead of closed). :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
why would you do that ? it is one or the other: 1. create a single instance, and now loop {initialize variables, show, hide} until app exits OR 2. loop {create an instance, show, close } until app exits it does not make sense to create a new instance, while a previous one is still around (hidden instead of closed). :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
Sorry Luc Patty , I do not understand you , ok lets go slowly first : the user choose new game > The PlagGame Form Will Be shown(By Calling The Create Method witch create an instance from PlayGame Form). Second : the user Win Or Lose a Message Box Appear And Asking Him If He Want Play again ??-the PlayGame Form Still Exist - third: in this step i need to ReShow the PlayGame Form to looks like an other new game if i hide the current PlayGame form i need than to call it again with out create another instance How can I ???? sorry I know that my question may be bored :-O thanks any way Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
thank you Luc Pattyn for your replay I do an instance in a method and hide the current form ,and it works , but i think when i hide the current form to call the new instance that i make an over load in memory because the current form is still exists . what do you think , How can i close the current form to cal its new instance ?? thanks again :) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
Adding to my previous reply: you may find it difficult to organize the looping in a single form; the natural solution is to have two form classes, the main one organizing the looping (and maybe showing highest scores, or whatever), the second one representing a single game. So now the app would: create and show a main form, then loop over the following steps { create a game form, show it (maybe as a dialog) (and maybe you want to temporarily hide the main form) let the game run, when the game is done, make mainform visible again (if hidden), and close the game form } As I said before you could reuse the game form (by hiding, not closing it), but I see no real advantage here, since now you must reinitialize the game form explicitly for consecutive runs of the game. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
Adding to my previous reply: you may find it difficult to organize the looping in a single form; the natural solution is to have two form classes, the main one organizing the looping (and maybe showing highest scores, or whatever), the second one representing a single game. So now the app would: create and show a main form, then loop over the following steps { create a game form, show it (maybe as a dialog) (and maybe you want to temporarily hide the main form) let the game run, when the game is done, make mainform visible again (if hidden), and close the game form } As I said before you could reuse the game form (by hiding, not closing it), but I see no real advantage here, since now you must reinitialize the game form explicitly for consecutive runs of the game. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
of course you are Right ,and i did what you said when the user finish close the game form an return to the main form . but i do not want to return to the main form again after finishing the game , i want the game form to reshow again as if it reloaded ,that is the problem . :^) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
of course you are Right ,and i did what you said when the user finish close the game form an return to the main form . but i do not want to return to the main form again after finishing the game , i want the game form to reshow again as if it reloaded ,that is the problem . :^) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
The main form can organize that without being visible. And as I said before, the game form can either be reused or be replaced by a new instance (that would cause some flickering I guess). :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
thank you Nisar Inamdar for your replay . i do a method witch create an instant from the form and call it and hide the current form ,and it works . but i have a question when i hide the current form every time the user win or lose the form still exists ,do you think that is over load in memory , and bad performance , i do not know i am asking thanks again for your Useful Replay :) Mona ,
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
I believe you can do a Form.Close() and then a Form.Dispose() in order to clean up the memory, instead of having the form stick around w/ Form.Hide.
-
I believe you can do a Form.Close() and then a Form.Dispose() in order to clean up the memory, instead of having the form stick around w/ Form.Hide.