3个form:StartForm(主窗体),frmWelcome,frmLogin
[STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
主窗口代码:
 public StartForm()
        {
            InitializeComponent();
            // 显示欢迎窗口
            frmWelcome frm1 = new frmWelcome();
            if (frm1.ShowDialog() == DialogResult.OK)
            {
                frmLogin frm2 = new frmLogin();
                if (frm2.ShowDialog() != DialogResult.OK)
                {
                    //  登入不成功
                    this.Close();
                }
            }
        }
欢迎窗口代码(timer1是组件,控制5秒后关闭欢迎窗口):
    public partial class frmWelcome : Form
    {
        public frmWelcome()
        {
            InitializeComponent();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            timer1.Enabled = false;
            timer1.Stop();
            this.Close();
        }
        private void frmWelcome_Load(object sender, EventArgs e)
        {
            //  5秒后关闭欢迎窗口
            timer1.Interval = 5000;
            timer1.Enabled = true;
            timer1.Start();
        }
    }
登入窗口登入按钮代码:
        private void button1_Click(object sender, EventArgs e)
        {
            // 登入成功,关闭登入窗口
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lldszy/archive/2007/09/21/1794788.aspx

posted on 2009-01-06 11:22  jackiejiao  阅读(251)  评论(0编辑  收藏  举报