|
-
December 30th, 2004, 04:42 AM
#1
Problem with Multiple Forms App (VS 2003B)
I am using Visual Studio.Net 2003B and I have to say that i am really pleased with
the Studio's Form Designer...It really helps you handle the events ,the properties and many other things.
BUT I have some problems with the organisation of the Forms the Designer proposes(or is it forces you..?).
It implements a form as a Form.h library file and a main CppForm for example .cpp file which calls the
Forms class at the beginning.
Application::Run(new Form1());
Let's say i create a second form using Studio's Wizard,Add New Item->Windows Form.
That means a second Form2.h and a Form2.cpp is created.
What i want to do is by clicking a button at the Form1 to Show Form2..
How do I do that.
Does it have anything to do with PArent and Child Forms?
I found the following code for Child and Parent Forms but the problem is i want to
put this code into the Form1.h event handler for my button..
private:
void CreateMyChildForm ()
{
// Create a new form to represent the child form.
Form* child = new Form();
// Increment the private child count.
childCount++;
// Set the text of the child form using the count of child forms.
String* formText = String::Format( S"Child {0}", __box(childCount));
child->Text = formText;
// Make the new form a child form.
child->MdiParent = this;
// Display the child form.
child->Show();
}
If i want to fire a new instance of Form2 class how would i do it as far as the event handler of Button1 let's say
is in Form1.h and cannot "see" the Form2 class located in Form2.h..
PLS HELP
-
December 30th, 2004, 05:22 PM
#2
Re: Problem with Multiple Forms App (VS 2003B)
I'm not sure this is what you want....
Firstly, include the header file for Form2 at the beginning of Form1.h
The code to launch Form 2 would then be:
Code:
private: System::Void btnCnt_Click(System::Object * sender, System::EventArgs * e)
{
Form2* dlgForm2 = new Form2();
if(dlgForm2->ShowDialog == DialogResult::OK)
{
//Put code here for an "OK" click on Form2 if required
}
}
I hope this helps
Lloydy
-
December 30th, 2004, 06:50 PM
#3
Re: Problem with Multiple Forms App (VS 2003B)
It helped and this is exactly what i want but i keep on getting this error when trying to debug:
error C2475: 'System::Windows::Forms::Form::ShowDialog' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
what should i do?
-
December 30th, 2004, 08:53 PM
#4
Re: Problem with Multiple Forms App (VS 2003B)
Sorry, try
Code:
private: System::Void btnCnt_Click(System::Object * sender, System::EventArgs * e)
{
Form2* dlgForm2 = new Form2();
if(dlgForm2->ShowDialog() == DialogResult::OK)
{
//Put code here for an "OK" click on Form2 if required
}
}
I left the brackets out after the ShowDialog.
Don't forget to rate the post if it helps
Lloydy
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
|