您的位置:首页 > 编程语言 > C#

C#Windows 窗体设计-实现欢迎界面-显示About窗体-在托盘中写入应用程序图标

2014-10-15 09:03 751 查看
一、实现欢迎界面

1.

private void Form1_Load(object sender, EventArgs e)
        {
            //MessageBox.Show("将窗体加载到内存","信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
            label1.Text = System.DateTime.Now.ToShortDateString();
            label2.Text = System.DateTime.Now.ToLongDateString();
            //timer2.Start();
            Welcome wel = new Welcome();
            wel.ShowDialog();
           

        }


2.



3.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fenhang
{
    public partial class Welcome : Form
    {
        public Welcome()
        {
            InitializeComponent();
        }

        private void Welcome_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            //this.BackgroundImage = Image.FromFile("image/1.jpg");
            timer1.Start();
            //this.timer1.Interval = 300000;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Welcome_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.timer1.Stop();
        }
    }
}



效果加载主窗体前会显示三秒中的欢迎界面。

二、显示About窗体

在C#中,可以通过”添加新项“给项目添加一个”关于框“,即About 窗体。点击主界面的关于按钮,弹出About窗体。

按钮时间响应:

private void button2_Click(object sender, EventArgs e)
        {
            AboutBox1 ab1 = new AboutBox1();

            //this.Hide();
            ab1.Show();
            
        }


三、在托盘中写入应用程序图标

需要使用NotifyIcon控件







代码如下:

private void notifyIcon1_MouseDoubleClick_1(object sender, MouseEventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Normal;
                this.Activate();
            }
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐