Form.Title

来源:互联网 发布:网络舆情管理的方法 编辑:程序博客网 时间:2024/05/14 05:04

using System;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private Timer timer1;
        private string title = "窗口标题为闪烁效果!      ";
        private StringBuilder sbTitle = new StringBuilder("窗口标题为闪烁效果!      ");

        public Form1()
        {
            InitializeComponent();
            timer1 = new Timer(this.components);
            timer1.Enabled = true;
            timer1.Interval = 300;
            timer1.Tick += new System.EventHandler(this.timer1_Tick);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //if (this.Text.Length < sbTitle.Length)
            //    this.Text = sbTitle.ToString(0, this.Text.Length + 1);
            //else
            //{
            //    sbTitle.Append(sbTitle[0]);
            //    this.Text = sbTitle.Remove(0, 1).ToString();
            //}
            if (this.Text.Length < title.Length)
                this.Text = title.Substring(0, this.Text.Length + 1);
            else
            {
                string str = this.Text.Trim();
                this.Text = (str.Length > 0) ? this.Text.Replace(str[0], ' ') : null;
            }
        }
    }
}