特殊類型表單製作: 用C#實現啟動歡迎介面

來源:互聯網
上載者:User

第一步: 主程式啟動主表單(這裡表示為 form1)

如下:

    static class Program
    {
        /// <summary>
        /// 應用程式的主進入點。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }

第二步: 主表單( form1) 中的 _Load 事件中啟動歡迎介面 (form2)

如下:

      private void Form1_Load(object sender, EventArgs e)
        {
            //啟動表單
            Form2 MySplashForm = new Form2();
            MySplashForm.ShowDialog();
        }

 

第三步: 歡迎介面中控制介面的顯示方式並使用 timer 控制歡迎介面的消失時間 (實際中往往是讀取系統需要的配置資訊後消失)

如下:

  
        private void Form2_Load(object sender, EventArgs e)
        {
            //設定啟動表單
            this.FormBorderStyle = FormBorderStyle.None;
            this.BackgroundImage = Image.FromFile("test.jpg");
            this.timer1.Start();
            this.timer1.Interval = 10000;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            //...........讀取系統配置

 
            //關閉啟動表單
            this.Close();
        }

        private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            //關閉定時器
            this.timer1.Stop();
        }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.