G
Guest
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here
http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as
Starting with "Listing 2 - Changing the constructor of the modeless dialog to accept the parent object:" line and go onwards is what I'm trying to do
Basically, there is the main form, and then there's the modeless form. I want the modeless form act like a modal form, except that the modeless form won't block the main form, which is why I dislike modal form. The problem is that modeless form won't report the dialog result, so I came to a webpage link above. Read the example, tried to do it, got stuck
I've read up about forward declaration, but that didn't help. It still kept saying that the main form's class is undefined (C2027 error from compiler). Maybe I'm doing it wrong somehow. This is how it looks like in my current project (cutting out all the uncessary clutter)
main.
===
namespace bla
#include "modelessform.h
public __gc class main : public System::Windows::Forms::For
public: void launchform(
modelessform* box = new modelessform(this)
void showsomething(modelessform* box
// get text from modelessform and put it into main's textBo
statusBar->Text = box->gettext()
modelessform.
=========
namespace bla
public __gc class main; // forward declaratio
public __gc class modelessform : public System::Windows::Forms::For
// created another constructor..
public: modelessform(main* parent
InitializeComponent()
theparentform = parent
String* gettext(){return textBox->Text;
private: main* theparentform
// somewhere very down below..
private: System::Void buttonok_Click(System::Object * sender, System::EventArgs * e
parentform->gettext(); // Compiler spits out C2027 here, saying use of undefined type 'blah::main
Close()
Given that everything compiles and runs fine, no errors/warnings, windows form pops up fine, but when trying the nifty sending parent object trick like the web page does it in C#, I get that annoying C2027. Maybe I'm missing something here or there, or have a misunderstanding that this can be done in C++ but can't. I would think a forward declaration would fix the problem, but that only fixes half the problem. Including the forward declaration of class main in class modeless form fixed the compiler error that main* wasn't define. Moving on, I then try to make theparentform pointer access its own function, and then boom, C2027 error
Help?
http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as
Starting with "Listing 2 - Changing the constructor of the modeless dialog to accept the parent object:" line and go onwards is what I'm trying to do
Basically, there is the main form, and then there's the modeless form. I want the modeless form act like a modal form, except that the modeless form won't block the main form, which is why I dislike modal form. The problem is that modeless form won't report the dialog result, so I came to a webpage link above. Read the example, tried to do it, got stuck
I've read up about forward declaration, but that didn't help. It still kept saying that the main form's class is undefined (C2027 error from compiler). Maybe I'm doing it wrong somehow. This is how it looks like in my current project (cutting out all the uncessary clutter)
main.
===
namespace bla
#include "modelessform.h
public __gc class main : public System::Windows::Forms::For
public: void launchform(
modelessform* box = new modelessform(this)
void showsomething(modelessform* box
// get text from modelessform and put it into main's textBo
statusBar->Text = box->gettext()
modelessform.
=========
namespace bla
public __gc class main; // forward declaratio
public __gc class modelessform : public System::Windows::Forms::For
// created another constructor..
public: modelessform(main* parent
InitializeComponent()
theparentform = parent
String* gettext(){return textBox->Text;
private: main* theparentform
// somewhere very down below..
private: System::Void buttonok_Click(System::Object * sender, System::EventArgs * e
parentform->gettext(); // Compiler spits out C2027 here, saying use of undefined type 'blah::main
Close()
Given that everything compiles and runs fine, no errors/warnings, windows form pops up fine, but when trying the nifty sending parent object trick like the web page does it in C#, I get that annoying C2027. Maybe I'm missing something here or there, or have a misunderstanding that this can be done in C++ but can't. I would think a forward declaration would fix the problem, but that only fixes half the problem. Including the forward declaration of class main in class modeless form fixed the compiler error that main* wasn't define. Moving on, I then try to make theparentform pointer access its own function, and then boom, C2027 error
Help?