zoukankan      html  css  js  c++  java
  • 设计闪烁的窗体

    1、概述

        qq对话框接收到消息时,如果对话框不是活动窗体,对话框就会闪烁来提示用户有新消息需要阅读,本文就是要实现这种形式的闪烁窗体。

    2、设计详情

        .NET没有直接提供实现窗体闪烁的类和方法,需要调用Windows的API函数FlashWindow()实现。该函数在c#中的声明如下:

         [DllImport("user32")]
         private static extern long FlashWindow(IntPtr handle,bool bInvert);

    此函数可以实现窗体闪烁,但只能闪烁一次,如果要实现多次闪烁,可以借助定时器Timer组件实现。

    注意:在Windows应用程序中使用Windows API 函数时,必须引入命名空间 System.Runtime.InteropServices;

    3、窗体设计

        

    4、程序代码

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 using System.Runtime.InteropServices;
    10 
    11 namespace Kaifafanli
    12 {
    13     
    14     public partial class Form6 : Form
    15     {
    16         [DllImport("user32")]
    17         private static extern long FlashWindow(IntPtr handle,bool bInvert);
    18         public Form6()
    19         {
    20             InitializeComponent();
    21         }
    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             this.timer1.Enabled = true;
    31         }
    32 
    33         private void button2_Click(object sender, EventArgs e)
    34         {
    35             this.timer1.Enabled = false;
    36         }
    37 
    38     }
    39 }
    View Code
  • 相关阅读:
    【转载】关于C#中动态加载AppDomain的问题
    poj2239
    poj2231
    poj2229
    poj2234
    poj2236
    前 路
    只含一个单词的句子
    做人准则
    改变人生的32句励志名言
  • 原文地址:https://www.cnblogs.com/net064/p/5664437.html
Copyright © 2011-2022 走看看