Main method:
***************************************************************
Application.CurrentCulture = new System.Globalization.CultureInfo("de-DE",
false);
Splasher.Show();
MainForm frm = null;
try
{
frm = new MainForm();
}
catch
{
Splasher.Close();
System.Windows.Forms.MessageBox.Show("Anmeldung an die Datenbank nicht
möglich. Bitte wenden Sie sich an Ihren Systemadministrator.",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
return;
}
UnhandledExceptionHandler ueh = new UnhandledExceptionHandler();
Application.ThreadException += new
System.Threading.ThreadExceptionEventHandler(ueh.OnThreadException);
System.AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(frm);
*************************************************************************
In MainForm cosntructor:
*********************************************************************
// Update splash screen
Splasher.Status = "Lesung Default-Werte...";
// Load dynamic modules
this.FindPlugins(System.IO.Path.GetDirectoryName(Application.ExecutablePath)
, "EloSoft.Windows.Forms.IPlugin");
Splasher.Status = "Module laden...";
// Read Default Values
ReadDefaultValues();
// Update splash screen
Splasher.Status = "Öffnung Logon-Form...";
// Create the Login form
Login frmLogin = new Login();
// Close the splash screen
Splasher.Close();
// Show Login form
frmLogin.ShowDialog();
if(this.userInfo != null)
{
// Add the Startup Page
TransportSearch frm;
try
{
frm = new TransportSearch();
}
catch(Exception ex)
{
EloSoft.Windows.Forms.MessageBox.Show(this, Application.ProductName,
EloSoft.Windows.Forms.Form.GetMessageText(EloSoft.Windows.Forms.ErrorMessage
s.CannotOpenForm), ex);
return;
}
AddNewTab(frm);
this.GetTemplates(10);
this.Visible = true;
this.docs.FocusedDocument = this.docs.TabStrips[0].Documents[0];
this.docs.FocusedDocument.Control.Focus();
}
****************************************************************************
**********8
Stoitcho Goutsev (100) said:
Hi Albert,
What exactly your concerns are. If you do that at the begining only the
login form is visible that is because you haven't start the application
message loop yet, but the login form is opened with ShowDialog and it
has
to
be active and working.
Can you post some sample code demonstrating your problem.
--
B\rgds
100 [C# MVP]
Albert Tollkuçi said:
Hi guys,
The MainForm of my application is not visible at startup. In the contructor
I show a modal dialog (the login form) and I want to set the focus to this
form. I have tried a lot of options but it doesn't work.
Any help is appreciated.
Thanx,
Albert