2014-12-31 22 views
1

我需要在運行我的應用程序時同時顯示Splash屏幕和登錄窗體。如何在同一時間使用c顯示Splashscreen和登錄窗體#

static void Main() 
    { 
     Application.EnableVisualStyles(); 
     Application.SetCompatibleTextRenderingDefault(false); 

     SplashImageForm f = new SplashImageForm(); 
     f.Show(); 

     Application.Run(f); 
     Application.Run(new Form1()); 
    } 
+0

使用多線程 – Codeek

+0

我可以得到任何示例嗎? –

+0

http://stackoverflow.com/questions/13406077/display-multiple-forms-when-c-sharp-application-starts – Codeek

回答

1

從Form1中顯示你的splashscreen,並將splashscreens的父窗口設置爲form1。因爲我認爲這需要在一段時間後關閉。這也將覆蓋這樣的事實:如果關閉表單1,由於父子關係,啓動畫面也將關閉。

private void Form1_Load(object sender, EventArgs e) 
{ 
    var f = new SplashImageForm(); 
    f.Show(this); 
} 
+0

working .. thanks .. –

2

試試這個:

登錄表單:

public partial class LoginForm : Form 
{ 


    private void buttonLogin_Click(object sender, EventArgs e) 
    { 
     //check username password 
     if(texboxUser == "user" && texboxPassword == "password") 
     { 
      DialogResult = DialogResult.OK; 
      Close(); 
     } 
     else 
     { 
      MessageBox.Show("Wrong user pass"); 
     } 
    } 
} 

在飛濺的形式:

private void Splash_Shown(object sender, EventArgs e) 
    { 
     LoginForm loginF = new LoginForm(); 

     loginF.ShowDialog(); 

     if (loginF.DialogResult == DialogResult.OK) 
     { 
      loginF.Close(); 
     } 
    } 

在Program.cs的:

static void Main() 
    { 
     Application.EnableVisualStyles(); 
     Application.SetCompatibleTextRenderingDefault(false); 
     Application.Run(new Splash()); 

    } 
相關問題