Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create a new form

Posted on 2006-07-18
4
266 Views
Last Modified: 2010-04-16
I have a windows form, now I want  to minimize it and then make a new form. How could I do that, and by the way I want to get the position information. Thanks!
0
Comment
Question by:ed_dalian
4 Comments
 
LVL 12

Accepted Solution

by:
topdog770 earned 300 total points
ID: 17132377
I create a new windows application and added a button2 with click event...

In this example, I create a second copy of the first form and change the window title.. so we can see the difference between the first and second window.. when hiding the first form, I also hide it on the taskbar so our users don't see multiple windows for this program after clicking on the button.

            private void button2_Click(object sender, System.EventArgs e)
            {
                  this.CenterToScreen();

                  Form1 dlg = new Form1();
                  dlg.Text = "Second Window";
                  dlg.Left = this.Left;
                  dlg.Top = this.Top;
                  dlg.Size = this.Size;
                  
                  // make the parent window hidden
                  this.Hide();
                  this.ShowInTaskbar = false;

                  if( dlg.ShowDialog() == DialogResult.OK )
                  {
                        Application.Exit();
                  }
                  else
                  {
                        this.Show();
                        this.ShowInTaskbar = true;
                  }
0
 
LVL 2

Assisted Solution

by:Linky
Linky earned 100 total points
ID: 17132383
So you want a new form to appear when you minimize the form you have now? Say you have Form1.cs and Form2.cs and you want to make a new one. In the code you do:

Form2 newForm = new Form2();

Then to make it appear you do:

newForm.Show();

To get the position information its just:

Form2.Location.X;
Form2.Location.Y;

To make a new form when you minimize a form you need to create an event handler function.
0
 
LVL 2

Assisted Solution

by:MyersA
MyersA earned 100 total points
ID: 17132977
You can use the SizeChanged event on the Form that'll be minimized.

Create a SizeChanged event handler:
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

Then you can use this code in the eventhandler:

private void Form1_SizeChanged(object sender, EventArgs e)
{
        if (this.WindowState == FormWindowState.Minimized)
        {
                Form newForm = new Form();
                newForm.Show();
                MessageBox.Show(newForm.Location.X.ToString());  //newForm X coordinates
                MessageBox.Show(newForm.Location.Y.ToString());  //newForm Y coordinates
        }
}
0
 

Author Comment

by:ed_dalian
ID: 17135559
Thanks, all of you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

837 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