Go to Post Listen, my team lost in the finals to that alliance, and I've never suffered a more entertaining arse-kicking. Case closed. - Petey [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 17-09-2006, 12:49
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 Forms

I am using Visual C++ 2005 Express Edition with .NET2 Framework to create an application with multiple forms.

I have one main form which is the MDI (Multiple Document Interface) parent. Then I have multiple other MDI Children forms. I am using the designer to create my forms and then using the code editor to program the functionality that I want. This way I use all header files, no .cpp files.
I am able to access/inherit the other MDI Children forms from the main parent form, using this syntax, static Form1^ form1 = gcnew Form1;. And I also have the #include "Form1.h" defined in the main.h.

The problem occurs when I try to inherit the main form or any of its components form the other forms. For example, I need to inherit seralPort1 form main.h, but I can't. It gives me some basic errors which are related to not including the main.h in the other form, but I did include it.
If I add this under the public ref class Form1...
private: static Main::serialPort1^ serialport = gcnew Main::serialPort1; I get errors like Main is an undecleared identifier... and so on.

I searched the help files and the internet, but I could not find anything helpful. Now I know that C (RC code ) and C++ are quite different, but I don't know what these differences are.

Can you guys help me?

Thanks a lot
  #2   Spotlight this post!  
Unread 18-09-2006, 15:46
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 Forms

No one here uses Visual C++ 2005?
I have searched everywhere and I can't find anything on this.
  #3   Spotlight this post!  
Unread 18-09-2006, 16:09
Imajie Imajie is offline
Registered User
AKA: James Letendre
FRC #0195 (Cyber Knights)
Team Role: Electrical
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Southington
Posts: 114
Imajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud of
Send a message via AIM to Imajie
Re: Visual C++ 2005 Forms

I use Visual C#, but I don't know how similar the two are.
__________________
2007 UTC Champions Thanks 1124 and 558
2007 UTC GM Industrial Design Award

2006 Newton Divisional Winners
2006 Championship finalists
(Thanks 25 and 968 for picking us!)
2006 National Innovation in Control
  #4   Spotlight this post!  
Unread 18-09-2006, 18:17
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 Forms

Quote:
Originally Posted by Imajie
I use Visual C#, but I don't know how similar the two are.
I think they are close. How do you communicate between multiple forms?
  #5   Spotlight this post!  
Unread 18-09-2006, 22:14
Imajie Imajie is offline
Registered User
AKA: James Letendre
FRC #0195 (Cyber Knights)
Team Role: Electrical
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Southington
Posts: 114
Imajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud of
Send a message via AIM to Imajie
Re: Visual C++ 2005 Forms

Are you tring to use variables between forms?
I don't think that it is possible in C# to go between to forms with the same variables. C# doesn't have headers like C and C++ it has just source code and reference files that you add like a database or pictures, sound, ect.
__________________
2007 UTC Champions Thanks 1124 and 558
2007 UTC GM Industrial Design Award

2006 Newton Divisional Winners
2006 Championship finalists
(Thanks 25 and 968 for picking us!)
2006 National Innovation in Control
  #6   Spotlight this post!  
Unread 19-09-2006, 16:20
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 Forms

Quote:
Originally Posted by Imajie
Are you tring to use variables between forms?
I don't think that it is possible in C# to go between to forms with the same variables. C# doesn't have headers like C and C++ it has just source code and reference files that you add like a database or pictures, sound, ect.
I am using C++ and yes, I am trying to share variable as well as objects, such as serialPort1, between different forms. The object is only initialized in one form but I need to use it others. Any ideas?

Thanks
  #7   Spotlight this post!  
Unread 19-09-2006, 17:15
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Visual C++ 2005 Forms

Quote:
Originally Posted by 6600gt
I am using C++ and yes, I am trying to share variable as well as objects, such as serialPort1, between different forms. The object is only initialized in one form but I need to use it others. Any ideas?

Thanks
I don't know how to do this in C++, but I'm sure it'd be similar to what I'd do in C#.

Create a class with a name such as Globals, with static members for everything that you need to share.
Code:
public class Globals 
{
    public static int someNumber;
    public static bool someBoolean;
   // .. etc...
}
Then those could be accessed from anywhere, using Globals.someNumber, Globals.someBoolean, etc.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
  #8   Spotlight this post!  
Unread 20-09-2006, 00:05
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Visual C++ 2005 Forms

Create a new class that extends from the standard Windows form class.

Add class variables for variables you want to pass in from the calling form.

Now you need to copy the variable from the calling form into your new form class.

You can do this a number of ways: overload the show method (or any other method, or create a new one) to include parameters for all the variables you want to share, and in that method copy the parameters into the class variable.

Or add a constructor to your new form object where you can pass in the varilables you want to share as parameters, and again copy the parameters into the class variable.

Sorry, no code to show you. Just make sure you don't run into synchronization problems with the calling forms shared variables. Cases like this usually call for a modal form so that the calling form execution is blocked until the new form returns.
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
forms Michael Leicht Inventor 2 06-03-2006 17:24
Release Forms??? jakey General Forum 3 28-02-2006 13:08
Forms Josh Siegel 3D Animation and Competition 1 15-02-2004 13:09
medical forms archiver 1999 1 23-06-2002 22:34
Location of Forms? Nicoleaqueen General Forum 2 06-01-2002 21:10


All times are GMT -5. The time now is 23:03.

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