现在的位置: 首页 > 综合 > 正文

设置闪烁的标题栏

2012年11月24日 ⁄ 综合 ⁄ 共 3426字 ⁄ 字号 评论关闭

Frm_Main.cs

View Code

 1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.Runtime.InteropServices;
9
10 namespace FlashWindowBar
11 {
12 public partial class Frm_Main : Form
13 {
14 public Frm_Main()
15 {
16 InitializeComponent();
17 }
18
19 //重写API函数,用来实现窗体标题栏闪烁功能
20 [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
21 public static extern bool FlashWindow(IntPtr handle, bool bInvert);
22
23 private void timer1_Tick(object sender, EventArgs e)
24 {
25 FlashWindow(this.Handle,true);//启用窗体闪烁函数
26 }
27
28 private void button1_Click(object sender, EventArgs e)
29 {
30 timer1.Enabled = true;//启动计时器
31 }
32
33 private void button2_Click(object sender, EventArgs e)
34 {
35 timer1.Enabled = false;//关闭计时器
36 }
37 }
38 }

Frm_Main.designer.cs

View Code

 1 namespace FlashWindowBar
2 {
3 partial class Frm_Main
4 {
5 /// <summary>
6 /// 必需的设计器变量。
7 /// </summary>
8 private System.ComponentModel.IContainer components = null;
9
10 /// <summary>
11 /// 清理所有正在使用的资源。
12 /// </summary>
13 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
14 protected override void Dispose(bool disposing)
15 {
16 if (disposing && (components != null))
17 {
18 components.Dispose();
19 }
20 base.Dispose(disposing);
21 }
22
23 #region Windows 窗体设计器生成的代码
24
25 /// <summary>
26 /// 设计器支持所需的方法 - 不要
27 /// 使用代码编辑器修改此方法的内容。
28 /// </summary>
29 private void InitializeComponent()
30 {
31 this.components = new System.ComponentModel.Container();
32 this.pictureBox1 = new System.Windows.Forms.PictureBox();
33 this.button1 = new System.Windows.Forms.Button();
34 this.button2 = new System.Windows.Forms.Button();
35 this.timer1 = new System.Windows.Forms.Timer(this.components);
36 ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
37 this.SuspendLayout();
38 //
39 // pictureBox1
40 //
41 this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
42 this.pictureBox1.Location = new System.Drawing.Point(0, 0);
43 this.pictureBox1.Name = "pictureBox1";
44 this.pictureBox1.Size = new System.Drawing.Size(325, 127);
45 this.pictureBox1.TabIndex = 0;
46 this.pictureBox1.TabStop = false;
47 //
48 // button1
49 //
50 this.button1.Location = new System.Drawing.Point(55, 50);
51 this.button1.Name = "button1";
52 this.button1.Size = new System.Drawing.Size(75, 23);
53 this.button1.TabIndex = 1;
54 this.button1.Text = "开始闪烁";
55 this.button1.UseVisualStyleBackColor = true;
56 this.button1.Click += new System.EventHandler(this.button1_Click);
57 //
58 // button2
59 //
60 this.button2.Location = new System.Drawing.Point(196, 50);
61 this.button2.Name = "button2";
62 this.button2.Size = new System.Drawing.Size(75, 23);
63 this.button2.TabIndex = 2;
64 this.button2.Text = "停止闪烁";
65 this.button2.UseVisualStyleBackColor = true;
66 this.button2.Click += new System.EventHandler(this.button2_Click);
67 //
68 // timer1
69 //
70 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
71 //
72 // Frm_Main
73 //
74 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
75 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
76 this.ClientSize = new System.Drawing.Size(325, 127);
77 this.Controls.Add(this.button2);
78 this.Controls.Add(this.button1);
79 this.Controls.Add(this.pictureBox1);
80 this.Name = "Frm_Main";
81 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
82 this.Text = "设置闪烁的标题栏";
83 ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
84 this.ResumeLayout(false);
85
86 }
87
88 #endregion
89
90 private System.Windows.Forms.PictureBox pictureBox1;
91 private System.Windows.Forms.Button button1;
92 private System.Windows.Forms.Button button2;
93 private System.Windows.Forms.Timer timer1;
94 }
95 }

 

抱歉!评论已关闭.