![]() |
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 |
Re: Visual C++ 2005 Forms
No one here uses Visual C++ 2005?
I have searched everywhere and I can't find anything on this. |
Re: Visual C++ 2005 Forms
I use Visual C#, but I don't know how similar the two are.
|
Re: Visual C++ 2005 Forms
Quote:
|
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. |
Re: Visual C++ 2005 Forms
Quote:
Thanks |
Re: Visual C++ 2005 Forms
Quote:
Create a class with a name such as Globals, with static members for everything that you need to share. Code:
public class Globals |
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. |
| All times are GMT -5. The time now is 03:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi