[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Create a new form

Posted on 2006-07-18
4
Medium Priority
?
296 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
[X]
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
4 Comments
 
LVL 12

Accepted Solution

by:
topdog770 earned 900 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 300 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 300 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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