Hey all,

I am designing a budgeting program, not for any particular reason, and am having trouble with my new budget "wizard". I'm just storing the budget info in an xml file, and so far the program can load and modify info (I've yet to implement saving), but it cannot create a new budget file. I have several forms opening successfully off the main window (Home.h), but am having trouble in this particular instance.

Goal: when a user goes to file->new, they get a "wizard" of sorts with four screens:
1) welcome/give the budget a name
2) add income categories
3) add expense categories
4) congratulations/finish

Right now the first screen is opening properly using the following code in Home.h. The problem is progressing to the next window.

#include "NewBudget1.h"
...
		 //create a new budget
private: System::Void newBudgetToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 NewBudget1 ^nb1 = gcnew NewBudget1;
			 nb1->ShowDialog();
		 }

In NewBudget1 I have a welcome message and text box for the name, and next and cancel buttons. Here is the appropriate code for the next button:

#include "NewBudget2.h"
...
this->btnNext->Click += gcnew System::EventHandler(this, &NewBudget1::btnNext_Click);
...
private: System::Void btnNext_Click(System::Object^  sender, System::EventArgs^  e) {
			 NewBudget2 ^nb2 = gcnew NewBudget2;
			 this->Close();
			 nb2->ShowDialog();
		 }

My goal for the above code is to have the next form replace the first form, but I get the following compile errors:

Error	1	error C2065: 'NewBudget2' : undeclared identifier	...\NewBudget1.h	163
Error	2	error C2065: 'nb2' : undeclared identifier	...\NewBudget1.h	163
Error	3	error C2061: syntax error : identifier 'NewBudget2'	...\NewBudget1.h	163
Error	4	error C2065: 'nb2' : undeclared identifier	...\NewBudget1.h	165
Error	5	error C2227: left of '->ShowDialog' must point to class/struct/union/generic type	...\NewBudget1.h	165

I'm pretty sure that if I fix the first error the others will go away, but I can't figure why it can't find NewBudget2 when I have the include there right at the top. I've tried switching NewBudget2 for another random subform (New Category form), and that works fine. I get the same problem in NewBudget2 when trying to go forward to NewBudget3 or back to NewBudget1, using the same code.

While I'm far from a C++ expert, I'm not a completely new to it either. I'm very close to finishing the program, and this is the first time I've had to seek help from a source other than Google. I'd appreciate any help, as I'm stumped.

Thanks,
--Rikki

If NewButton2 is referenced in NewButton1.h then NewButton2.h must be included in NewButton1.h Your problem sounds like you just need to get the includes in the correct order.

I believe I have them in the correct order. NewBudget1 is referenced in Home.h, so NewBudget1.h is included in Home.h. NewBudget2 is referenced in NewBudget1.h, so NewBudget2.h is included in NewBudget1.h.

EUREKA!

I've just realized my problem is a cyclic dependency. I've fixed part of the problem: Home.h successfully opens NewBudget1 as before, but now NewBudget1 can go forward to NewBudget2, and so on. The problem is I want to be able to go back, hence the cyclic dependency.

My new problem is, what is the best solution? Removing the ability to go back seems like a bad design.

At the moment I can't get the NewBudget2 to be right over top of NewBudget1, but if it was, then just closing NewBudget2 would effectively go back, but how would I cancel out of the wizard altogether? How simple/possible is it to get a handle on all of the other subforms and close them too?

This question has already been answered. Start a new discussion instead.