Go to Post You don't have enough money, you're under-staffed, you're not quite sure what the customer wants, requirements change, and they want it yesterday. - Kimmeh [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-12-2006, 16:59
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Visual C++ 2005 Designer

I am using the inbuilt designer to build a Multi Document Interface. Now I can inherit the Children forms form the Parent and display them or access their objects. The designer uses the Header flies for everything.

The Problem occurs when I try to inherit a object form the Parent form to one of the Children.

Example:
(Parent Form/parent.h)

#include "Child.h"

ref class Parent: ......
{
Child^ c = gcnew Child;(No problem here)

bla bla.....
}

But when I also try to do this
(Child Form/child.h)

#include "Parent.h"

ref class Child: ....
{
Parent^ p = gcnew Parent;(give me a bunch of errors that I know are not wrong)

bla bla

}
I can find anything on this on the internet or the help files.

Can some one explain some possible reasons or what it means? Thanks
  #2   Spotlight this post!  
Unread 17-12-2006, 19:34
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Visual C++ 2005 Designer

Can you post the errors you're getting?
  #3   Spotlight this post!  
Unread 18-12-2006, 16:16
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Form21.h(47) : error C2143: syntax error : missing ';' before '^'
Form21.h(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Form21.h(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Form21.h(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Form21.h(47) : error C3845: 'test::Form2::form': only static data members can be initialized inside a ref class or value type
I get same exact errors from cpp files too that have the #include "Form1.h".
These are very basic errors that i dont have but appear when i do this particular thing.

I am starting to think what i am trying to do is not possible or is really complicated.

Last edited by 6600gt : 18-12-2006 at 16:21.
  #4   Spotlight this post!  
Unread 18-12-2006, 17:35
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Visual C++ 2005 Designer

I'm pretty sure what you are trying to do is not possible. . .
Normally how it is a parent can't call methods of a child. I'm unsure why you would want create a parent in a child anyways because the child inherits the parent's methods. . . Depending on what you are planning on doing panels might be the way to go. The MSDN Help is a great tool for any programmer. The help section for Inheritance is at http://msdn.microsoft.com/library/de...nheritance.asp
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #5   Spotlight this post!  
Unread 18-12-2006, 17:46
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: Visual C++ 2005 Designer

Can you explain why the parent needs to call child functions. I am so confused.
  #6   Spotlight this post!  
Unread 18-12-2006, 17:58
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Visual C++ 2005 Designer

I was just now actually studying for my Software final and saw a section of notes that that will help explain Parent / Child even more. . .

2.3 Inheritance
·Allows the derivation of one class from another.
·Subclasses or child or derived classes contain all of the methods and attributes of the parent or super or base class.
·The subclass may override some of the inherited methods
·The subclass may also add new methods and attributes.
oExample: Military platform base class – robot, UAV, soldier, tank, airplane, etc. child classes.
·Specialization – a subclass that inherits from a superclass and has additional specification. Elevator button is a kind of control but all buttons are not elevator buttons. Elevator button is a specialized button.
·Generalization – the opposite of specialization.
·Inheritance increase reuse and thus reduces the total volume of code needed – less to write, test, document, etc.
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #7   Spotlight this post!  
Unread 19-12-2006, 00:48
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by Gamer930 View Post
I'm pretty sure what you are trying to do is not possible. . .
Normally how it is a parent can't call methods of a child. I'm unsure why you would want create a parent in a child anyways because the child inherits the parent's methods. . . Depending on what you are planning on doing panels might be the way to go. The MSDN Help is a great tool for any programmer. The help section for Inheritance is at http://msdn.microsoft.com/library/de...nheritance.asp
I have been pouring through that help, especially the inheritance part. I think I finally get it: I was trying to inherit from a form that had already inherited it. In the MDI forms I was inheriting the children form the parent, then I was trying to inherit the parent form the children again. And this wouldn't work.

I might just have to go with panels. Only think I don't like about them is that hey are not as easy as form windows to arrange and close and open as you wish.

Any other suggestions?
  #8   Spotlight this post!  
Unread 19-12-2006, 22:14
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
Any other suggestions?
I think what you are trying to do is call a method that is a member of the Parent class from a MDI child form of class Child. If that is not what you are trying to do then disregard the rest of this post, and I'm confused.

If you are trying call a method that is on the MDI parent form, then this has nothing to do with inheritance, other than that both classes must inherit from the System.Windows.Forms.Form class. Note that the Form class has a property called MdiParent that is a reference to the instance of the Form that is the MDI container. Now, to access methods that are members of the MDI parent, you have to cast that property as whatever class it really is. From what you posted, it would be:
Code:
Parent^ myParent = dynamic_cast<Parent^>(this->MdiParent);
From there you can call methods normally:
Code:
myParent->SomeMethod();
You do not use gcnew in this case because you don't want to create a new instance of the Parent class, you just need to use the reference and cast it correctly.
  #9   Spotlight this post!  
Unread 20-12-2006, 15:58
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Thanks.

I put this in

Quote:
Main^ m = dynamic_cast<Main^>(this->MdiParent);
and I got these errors

Quote:
Form3.h(268) : error C2065: 'Main' : undeclared identifier
Form3.h(268) : error C2065: 'm' : undeclared identifier
Form3.h(268) : error C2061: syntax error : identifier 'Main'
Yeah, I did put the #include "Main.h" above.


Last edited by 6600gt : 20-12-2006 at 16:01.
  #10   Spotlight this post!  
Unread 20-12-2006, 17:46
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: Visual C++ 2005 Designer

After reading through this (and your post from September about a similar type of issue), it's not readily apparent how your MDI project is set up. My first MDI project in VC++ took a lot of hours of hair pulling and coffee until I could readily pass information around.
If you would like, PM me and you can zip up & email me your project to look at. I'm assuming you've been using the free VC++ available from Microsoft's website?
  #11   Spotlight this post!  
Unread 20-12-2006, 21:32
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Visual C++ 2005 Designer

I am curious to see your project setup as well. You should have a Main.h which houses the Main class declaration, and a Main.cpp for the Main class's code. You should also have a Form3.h and a Form3.cpp. You need to make sure that any code that references the Main class from the Form3 class resides in the Form3.cpp, since you can't have Main.h include Form3.h while at the same time Form3.h includes Main.h since this will cause errors.

I zipped a simple MDI demo application and attached it to the post. I hope it shows what I am talking about.
Attached Files
File Type: zip CDHelp.zip (10.6 KB, 22 views)
  #12   Spotlight this post!  
Unread 21-12-2006, 15:47
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by esquared View Post
If you would like, PM me and you can zip up & email me your project to look at. I'm assuming you've been using the free VC++ available from Microsoft's website?
Yea. I will PM once I figure out what I am trying to do.


Quote:
I am curious to see your project setup as well. You should have a Main.h which houses the Main class declaration, and a Main.cpp for the Main class's code. You should also have a Form3.h and a Form3.cpp. You need to make sure that any code that references the Main class from the Form3 class resides in the Form3.cpp, since you can't have Main.h include Form3.h while at the same time Form3.h includes Main.h since this will cause errors.
So basically you are saying that I should put all my functions in the cpp file. I only need to really do this for the children, right? Currently, my project has everything in the header files. I was trying that but didn't know how to set it for this compiler. Thanks for the sample. This is exactly what I was looking for. When school finally ends tomorrow, I will try it out.

Last edited by 6600gt : 21-12-2006 at 15:50.
  #13   Spotlight this post!  
Unread 21-12-2006, 16:55
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
So basically you are saying that I should put all my functions in the cpp file. I only need to really do this for the children, right? Currently, my project has everything in the header files. I was trying that but didn't know how to set it for this compiler. Thanks for the sample. This is exactly what I was looking for. When school finally ends tomorrow, I will try it out.
The short answer to your question is that function declarations should go into the header files (along with documentation of what the functions do ), and the function definitions should go in the cpp files.

The long answer is best left to some research into good programming practices, you can always start with the ubiquitous Wikipedia (http://en.wikipedia.org/wiki/Header_file) to get more information.

-Eric
  #14   Spotlight this post!  
Unread 30-12-2006, 03:15
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Thanks for all the help.

Now I have a new problem and I can't find any useful information on it.

Main^ main = dynamic_cast<Main^>(this->MdiParent);

for(count = 0; count < 10; count++)
{
number = main->serialPort1->BytesToRead; //Error
}

Quote:
An unhandled exception of type 'System.NullReferenceException' occurred in GUI Control Interface.exe

Additional information: Object reference not set to an instance of an object.
This happens when I start sending some serial data form a PIC to the comp.

Searching on the internet hasn't explained it much.
  #15   Spotlight this post!  
Unread 30-12-2006, 03:56
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,185
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
T
This happens when I start sending some serial data form a PIC to the comp.
May I ask what type of project you are working on?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual C++ 2005 Forms 6600gt Programming 7 20-09-2006 00:05
LEGO digital designer tiffany34990 Chit-Chat 2 08-10-2005 07:13
Bridge Designer Cyberguy34000 Chit-Chat 4 13-08-2005 21:07
Graphic Designer / Animator Jay5780 Career 1 05-06-2001 20:05


All times are GMT -5. The time now is 09:58.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi