Maybe I cannot describe my purpose clearly.I know the difference between
modal and modeless dialog.I paste my simplyfied test code here,so you can
understand what I mean(I use vs2003 and Windows CE.NET emulator).You should
pay attention to myForm1_Load(...).
form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace panelscroll
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button2;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.button2 = new System.Windows.Forms.Button();
//
// button2
//
this.button2.Location = new System.Drawing.Point(64, 112);
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 255);
this.Controls.Add(this.button2);
this.Text = "Form1";
}
static void Main()
{
Application.Run(new Form1());
}
myForm1 frm = new myForm1();
private void button2_Click(object sender, System.EventArgs e)
{
//myForm1 frm = new myForm1();
//try
//{
frm.ShowDialog();
//}
//finally
//{
// frm.Dispose();
//}
}
}
}
form2.cs
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace panelscroll
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class myForm1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.Button button35;
private System.Windows.Forms.TextBox textBox35;
private System.Windows.Forms.Label label35;
private System.Windows.Forms.TabPage tabPage5;
private System.Windows.Forms.MainMenu mainMenu1;
public myForm1()
{
uint et;
et = GetTickCount();
InitializeComponent();
et = GetTickCount() - et;
MessageBox.Show("Load Time: " + et.ToString() + "ms");
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
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.tabControl1 = new System.Windows.Forms.TabControl();
this.button35 = new System.Windows.Forms.Button();
this.textBox35 = new System.Windows.Forms.TextBox();
this.label35 = new System.Windows.Forms.Label();
this.tabPage5 = new System.Windows.Forms.TabPage();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage5);
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(240, 268);
//
// button35
//
this.button35.Font = new System.Drawing.Font("Tahoma", 9F,
System.Drawing.FontStyle.Regular);
this.button35.Location = new System.Drawing.Point(160, 13);
this.button35.Size = new System.Drawing.Size(64, 20);
this.button35.Text = "button35";
//
// textBox35
//
this.textBox35.Font = new System.Drawing.Font("Tahoma", 9F,
System.Drawing.FontStyle.Regular);
this.textBox35.Location = new System.Drawing.Point(76, 13);
this.textBox35.Size = new System.Drawing.Size(80, 22);
this.textBox35.Text = "textBox35";
//
// label35
//
this.label35.Font = new System.Drawing.Font("Tahoma", 9F,
System.Drawing.FontStyle.Regular);
this.label35.Location = new System.Drawing.Point(8, 17);
this.label35.Size = new System.Drawing.Size(64, 20);
this.label35.Text = "label35";
//
// tabPage5
//
this.tabPage5.Controls.Add(this.button35);
this.tabPage5.Controls.Add(this.textBox35);
this.tabPage5.Controls.Add(this.label35);
this.tabPage5.Location = new System.Drawing.Point(4, 21);
this.tabPage5.Size = new System.Drawing.Size(232, 243);
this.tabPage5.Text = "5";
//
// myForm1
//
this.ClientSize = new System.Drawing.Size(298, 418);
this.Controls.Add(this.tabControl1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Text = "Form1";
this.Load += new System.EventHandler(this.myForm1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[DllImport("coredll.dll", EntryPoint="GetTickCount")]
public static extern uint GetTickCount();
private void myForm1_Load(object sender, System.EventArgs e)
{
/* if you remove the following comment,if you press mainform's
button2,then click X to close myform,repeat these steps
* you'll get an exception */
//this.WindowState = FormWindowState.Maximized;
}
}
}