This has been really bothering the crap out of me for the last few days.
I have dialogue box 1, the person can say continue (goto dialogue box 2) or exit.
If they continue, then dialogue box 2 let's them exit, or go back to box 1(goto dialgue box 1)
so it looks something like:
then for dialogue box 2:Code:Dialogue Box 1::OnOkay() Dialogue box 2 mybox2; mybox2.DoModal();
simple enough - if it clicks okay, it opens a modal dialogue box for 2. if i go back, it opens a modal box for 1. I can use this method and continue forever (i.e., box 1- box 2- box 1- box2). However, if for dialogue box 1 class I declare some arrays, for example, myarray[10001], myarray2[10001], I can only use this method to go back 2 or 3 times before my program crashes on me.Code:DIalogue box 2::Onback() { Dialogue box 1 mybox1; mybox1.DoModal(); }
If I remove these variables, crash goes away (and I'm not using these variables, just declaring them in the public class of dialogue box 1).
So it would seem that my method doesn't work very well........so my question is, if I go from dialogue box 1, to diaglogue box 2, and in box 2 I want to be able to move back to dialogue box 1, how can I without it crashing (assuming I leave the class variables in box 1)??
edit: by playing with message handling functions destroy (called when dialogue box destroyed) and init (when dialogue boix is made) i see that my boxes are never being destroyed - i'll create box 1, then i'll create box 2, then i'll create box 1 (without destroying box 2). So I guess that's how I'm running out of memmory.
Any suggestions on how to do something like:
create box 1
user selects to goto box 2
destroy box 1
create box 2
user selects to do back
destroy box 2
create box 1
edit2: Nope, that won't work - I tried calling dialoguebox1/2.DestroyWindow() so it destroys the window when it leaves it for the next dialogue box, but my program STILL crashes on me after a few iterations of moving backwards and forwards
edit3: Well, it appears a temporary solution is to NOT declare any arrays in the class header if the dialogue box may be created. If I remove all the arrays and just scope them to a function block, as opposed to the entire class, it still doesn't work, so what I have to do is create them on the heap (i.e., float *myarray = new float[10001], then after I destroy the window, call delete [] myarray)
Humph, i wish there was an easier way around this