M
maluman
Hello,
I have a following scenario:
I have two forms: Main and SplashScreen. The splash I show in Main
constructor. In Main_Load() method I hide the main form, than do an
application initialization (data connect etc). After that I hide the Splash
screen and Show the main form. Everything is ok, provided I don't show any
dialog to the user while the main form is hidden. When I do it (e.g. "The
data connection could not be established"), the main form shows minimalized.
I reproduced the problem in the end of this post.
Help much appreciated.
Regards, m.
I have two forms, Form1.cs and Form2.cs:
// -------------------------------------------------------------------------
-----------------------------
// Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace FormInBackground
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.OpenFileDialog openFileDialog1;
Form2 Splash = new Form2();
public Form1()
{
Splash.Show();
Splash.Refresh();
//
// 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 )
{
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.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
//
// Form1
//
this.ClientSize = new System.Drawing.Size(170, 87);
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.Hide();
// MessageBox.Show("With this Message Box Form1 runs minimized.");
Splash.Hide();
this.Show();
}
}
}
// End of form 1
// -------------------------------------------------------------------------
-----------------------------
// Form2.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace FormInBackground
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
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 )
{
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.label1 = new System.Windows.Forms.Label();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F,
System.Drawing.FontStyle.Regular);
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Size = new System.Drawing.Size(72, 32);
this.label1.Text = "Splash";
//
// Form2
//
this.ClientSize = new System.Drawing.Size(122, 71);
this.Controls.Add(this.label1);
this.Text = "Form2";
}
#endregion
}
}
// -------------------------------------------------------------------------
-----------------------------
I have a following scenario:
I have two forms: Main and SplashScreen. The splash I show in Main
constructor. In Main_Load() method I hide the main form, than do an
application initialization (data connect etc). After that I hide the Splash
screen and Show the main form. Everything is ok, provided I don't show any
dialog to the user while the main form is hidden. When I do it (e.g. "The
data connection could not be established"), the main form shows minimalized.
I reproduced the problem in the end of this post.
Help much appreciated.
Regards, m.
I have two forms, Form1.cs and Form2.cs:
// -------------------------------------------------------------------------
-----------------------------
// Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace FormInBackground
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.OpenFileDialog openFileDialog1;
Form2 Splash = new Form2();
public Form1()
{
Splash.Show();
Splash.Refresh();
//
// 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 )
{
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.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
//
// Form1
//
this.ClientSize = new System.Drawing.Size(170, 87);
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.Hide();
// MessageBox.Show("With this Message Box Form1 runs minimized.");
Splash.Hide();
this.Show();
}
}
}
// End of form 1
// -------------------------------------------------------------------------
-----------------------------
// Form2.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace FormInBackground
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
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 )
{
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.label1 = new System.Windows.Forms.Label();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F,
System.Drawing.FontStyle.Regular);
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Size = new System.Drawing.Size(72, 32);
this.label1.Text = "Splash";
//
// Form2
//
this.ClientSize = new System.Drawing.Size(122, 71);
this.Controls.Add(this.label1);
this.Text = "Form2";
}
#endregion
}
}
// -------------------------------------------------------------------------
-----------------------------