Open a Form within a Form

This is a discussion on Open a Form within a Form within the Windows Programming forums, part of the Platform Specific Boards category; If you are using C++ and through a button event want to open another form that you have created. How ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    Open a Form within a Form

    If you are using C++ and through a button event want to open another form that you have created. How do you code a scenario like this.

    My project is called "Fonster".
    In this project I have made 2 Forms named "Form1" and "ResultReport".

    In Form1 I have made a button. When I press this button I want the Form "ResultReport" to open.

    What should I write between the {}:
    I am trying something like this but it doesn´t work. It has to be some other things to do also.
    Perheps I have to declare the Form ResultReport ? This is the first time I am doing this thing.
    When I run the code, the compiler
    says that ResultReport must point to a class/struct/union/generic type.
    Code:
    private: System::Void OpenForm_Click(System::Object^  sender, System::EventArgs^  e) 
    		 
    {		
       ResultReport->Show();
    }
    Last edited by Coding; 01-26-2008 at 08:44 PM.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,612
    You need to create an instance of the window first, and then show it. This is a golden rule in many languages, including C++.
    But this is C++ dot net. You can do the same, with absolutely no relative difference in C#, with the same speed. Using C++ with dot net effectively cripples speed and not many are drawn to C++ dot net topics.
    Others sometimes helps on C#, but less so on C++ dot net from what I've seen.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Code:
    private: System::Void OpenForm_Click(System::Object^  sender, System::EventArgs^  e) 
    		 
    {		
       ResultReport->Show();
    }
    Assuming that the ResultReport form has been properly designed and it has been declared in the appropriate class as Rreport (that is, ResultReport Rreport) and the namespace is myNamespace, give the following a try:

    Code:
    private: System::Void OpenForm_Click(System::Object^  sender, System::EventArgs^  e) 
    		 
    {
       Rreport  = new myNamespace.ReportResult();		
       Rreport->Show();
    //   ResultReport->Show();
    }
    [/QUOTE]

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    383
    Yes, this is my problem also. What I will write and where to declare the form "ResultReport" because it is my first time I do it.

    In the ResultReport.h I have activated this, I believe this is needed:
    Code:
    private: System::Void ResultReport_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    I dont know if I should write any code here ?

    In the Form1.h, I write:
    Code:
    private: System::Void OpenForm_Click(System::Object^  sender, System::EventArgs^  e) 
    		 
    {
       Rreport  = new myNamespace.ReportResult();		
       Rreport->Show();
    }
    The compiler says this:

    'Rreport' : undeclared identifier
    'myNamespace' : is not a class or namespace name
    syntax error : identifier 'ReportResult'
    left of '->Show' must point to class/struct/union/generic type
    Last edited by Coding; 01-29-2008 at 08:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open Software License 3.0 Explained
    By laserlight in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 01-08-2008, 07:10 PM
  2. open empty file
    By mystic-d in forum C Programming
    Replies: 2
    Last Post: 11-16-2007, 09:27 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. To open or not to open ?
    By darfader in forum C Programming
    Replies: 7
    Last Post: 09-24-2003, 08:14 AM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21