Click to See Complete Forum and Search --> : Really simple communication between two forms.


joltgbg
January 19th, 2007, 06:16 PM
This is the case:
I have created 2 Forms. Called ParentForm and ChildForm.

Parentform has a button, when this is clicked ChildForm is displayed.

ChildForm should then manipulate controls in Parentform.

In, c++, java or c# I would just do somethig likethis in Childform.

((Parentform^)this->GetParent())->RunTheFunction()

However in Managed c++ using VS 2005 I get errors.

Parentform and ChildForm are both in the same namespace so this shouldnt be a problem.

First I get an error saying.
"is not a class or namespace"
So I include childform.h in Parenform.h
Now it works to press the button in PArentform to display Childform.

Once in Childform I need to include parentform.h to be able to do the cast.
And now the sky starts falling down.
The compiler starts complaining again in Parentform that "...is not a class or namespace"

Any ideas? I feel im missing something here?

Zaccheus
January 20th, 2007, 06:46 AM
http://www.codeguru.com/forum/showthread.php?t=411572
;)

Keep in mind that the syntax in that thread is for VS2003. For VS2005 you obviously have to use the new ref class and ^ syntax.

joltgbg
January 21st, 2007, 10:55 AM
Thank you!
You have been of great help. The problem is now solved. It was very annoying =)

http://www.codeguru.com/forum/showthread.php?t=411572
;)

Keep in mind that the syntax in that thread is for VS2003. For VS2005 you obviously have to use the new ref class and ^ syntax.

Zaccheus
January 21st, 2007, 11:12 AM
You are welcome.
:)