• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
遥远的梦
--心有多大, 世界就有多大
博客园    首页    新随笔    联系   管理    订阅  订阅
特殊类型窗体制作: 用C#实现启动欢迎界面

第一步: 主程序启动主窗体(这里表示为 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();
        }

posted on 2008-09-11 09:09  子逸  阅读(4240)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3