频道栏目
首页 > 资讯 > C# > 正文

C#编写启动欢迎界面

10-07-11        来源:[db:作者]  
收藏   我要投稿

第一步: 主程序启动主窗体(这里表示为 form1)
如下:
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
第二步: 主窗体( form1) 中的 _Load 事件中启动欢迎界面 (SplashForm)
如下:
        private void Form1_Load(object sender, EventArgs e)
        {
            //启动窗体
            SplashForm MySplashForm = new SplashForm ();
            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 SplashForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //关闭定时器
            this.timer1.Stop();
        }

    
相关TAG标签
上一篇:C#性能简析-集合容量的指定
下一篇:C# winform DataGridView 属性说明
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站