加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

【WinForm】C#编写启动欢迎界面

(2013-07-07 21:22:31)
分类: C#.NET开发

第一步: 主程序启动主窗体(这里表示为 form1)
如下:
    static class Program
    {
        ///
        /// 应用程序的主入口点。
        ///
        [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();
        }

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有