小弟初涉C#,在书上看到一个让窗体闪烁的例子,试着将它实现。
代码是这样的:
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 闪烁动画窗体
{
    public partial class Form1 : Form
    {
        [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
        public static extern bool FlashWindow(IntPtr handle,bool bInvert);
        public Form1()
        {
            InitializeComponent();
        }        private void pictureBox1_Click(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
            this.timer1.Interval = 500;
            this.timer2.Enabled = false;
            this.timer2.Interval=260;
        }        private void timer1_Tick(object sender, EventArgs e)
        {
            FlashWindow(this.Handle,true);//(1)
            pictureBox1.Visible = true;
            timer1.Enabled = false;
            timer2.Enabled = true;
        }        private void timer2_Tick(object sender, EventArgs e)
        {
            FlashWindow(this.Handle,true);//(2)
            pictureBox1.Visible = false;
            timer2.Enabled = false;
            timer1.Enabled = true;
        }
    }
}
我不明白的是这里的API函数(1)(2);意义何在,当我把这两句注销后程序运行的效果和没注销时时一样的。