How to embed a class into windows form?

Hi all,

This is the 1st time I am using Visual C++ to create a GUI, I hope to seek some advice for the qns I have.

I am using visual C++ windows form to create my GUI. Visual C++ generated a "form1.h" based on my design of the GUI. Now, I am trying to add in the "brain" of the GUI by instantiating an instance of a class(eg. Class Test) which I wrote previously.

I made this "test" obj as a private data member of my form1, however, when I compile, it gives an error, saying "Cannot define 'member' as a member of managed type". I understand tat this error is related to a non-POD C++ type in my class.

If I were to compile class test alone, it works perfectly fine. However, when I incoporate it into the form.h, compiler gives the above error.

My question is:
1. How can I resolve this error?
2. Am I correct to instantiate an instance of a class in the GUI form?

Thanks alot
FT :D
[960 byte] By [fulltime] at [2007-11-20 11:27:54]
# 1 Re: How to embed a class into windows form?
Hi,

I think alone compilation is the right way ! I mean to say it is better if you provide class declaration in seprate file.

-Anant
anantwakode at 2007-11-10 22:25:19 >
# 2 Re: How to embed a class into windows form?
Thks..

I found the solution in VC help.

To instantiate a class in form1.h, I can only declare a pointer to point to the type i wan to declare..

i.e test *a instead of test a.
I wonder why is there such an restriction..

Now, I have another qn. I will post it on a seperate thread to avoid confusion.
fulltime at 2007-11-10 22:26:30 >