?
Solved

Three subwindows inside a big window

Posted on 2007-07-29
7
Medium Priority
?
195 Views
Last Modified: 2013-12-17
How do I create a big window which has 3 subwindows inside it in C#.NET?
These 3 subwindows are one Internal explorer and 2 existing window applications.

Thanks,
Askingman


0
Comment
Question by:askingman
  • 2
4 Comments
 
LVL 9

Expert Comment

by:ripahoratiu
ID: 19590877
You mean a form?
Very simple: form is derived from control and IS a control. Once you set the .TopLevel property of a Form to false it acts as any control, you can add it to any other forms.
i.e.
Form1 frm1 = new Form1();
Form2 frm2 = new Form2();
frm2.TopLevel = false;
frm1.Constrols.Add(frm2);
....
frm1.Show();

or
You can use MDI forms.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19591154
I don't believe that was the question.  It looks more like how do I take existing windows, and make them a child of a parent window.  You could use FindWindow and SetParent API calls.

Bob
0
 

Author Comment

by:askingman
ID: 19597782
Here is my source code.  I tried form1 and form2 approach.  I only see From1, when I close Form1,
I see Form2, then Form2 close right away.   I still don't understand how to put IE window (IE browser - iexplore.exe) inside my big window (main, Form1 window).  My other 2 windows are existing window applications for example, (two existing winapp1.exe and winapp2.exe).

form1.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestingSubWindows
{
      /// <summary>
      /// Summary description for Form1.
      /// </summary>
      public class Form1 : System.Windows.Forms.Form
      {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.Container components = null;

            public Form1()
            {
                  //
                  // Required for Windows Form Designer support
                  //

                  InitializeComponent();

                 //
                  // TODO: Add any constructor code after InitializeComponent call
                  //
            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                  if( disposing )
                  {
                        if (components != null)
                        {
                              components.Dispose();
                        }
                  }
                  base.Dispose( disposing );
            }

            #region Windows Form Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                  //
                  // Form1
                  //
                  this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
                  this.BackColor = System.Drawing.SystemColors.Window;
                  this.ClientSize = new System.Drawing.Size(600, 600);
                  this.Name = "Form1";
                  this.Text = "Form1";
                  this.TransparencyKey = System.Drawing.Color.LightGray;

            }
            #endregion

            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                  Application.Run(new Form1());

                  Form1 frm1 = new Form1();
                  Form2 frm2 = new Form2();
                  frm2.TopLevel = false;

                  frm1.Controls.Add(frm2);

                  frm1.Show();
                  frm2.Show();

            }
      }

}

form2.cs


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace TestingSubWindows
{
      /// <summary>
      /// Summary description for Form2.
      /// </summary>
      public class Form2 : System.Windows.Forms.Form
      {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.Container components = null;

            public Form2()
            {
                  //
                  // Required for Windows Form Designer support
                  //
                  InitializeComponent();

                  //
                  // TODO: Add any constructor code after InitializeComponent call
                  //
            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                  if( disposing )
                  {
                        if(components != null)
                        {
                              components.Dispose();
                        }
                  }
                  base.Dispose( disposing );
            }

            #region Windows Form Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                  this.components = new System.ComponentModel.Container();
                  this.Size = new System.Drawing.Size(150,150);
                  this.Text = "Form2";
            }
            #endregion
      }
}


Thanks,
Askingman
0
 
LVL 9

Accepted Solution

by:
ripahoratiu earned 500 total points
ID: 19598366
Put this code in Form1 Load handler

       private void Form1_Load(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.TopLevel = false;
            this.Controls.Add(frm2);
            frm2.Show();
        }
or in the initialization method, and take out from Main
                  Form1 frm1 = new Form1();
                  Form2 frm2 = new Form2();
                  frm2.TopLevel = false;

                  frm1.Controls.Add(frm2);

                  frm1.Show();
                  frm2.Show();
You're running in main - Application.Run(new Form1()); - a new Form1() not frm1!!!!!!!!

You can also use panels in Form1 and add the forms to panels.



0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question