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
  • 相关阅读:
    安装python包
    在RHEL5.4上升级Python
    IronPython开发Windows Form程序总结
    Windows下手动配置Oracle Client的要点
    dreampie一个很不错的python命令行交互工具
    Eclipse插件汇总
    pyDbRowFactory Python版Db Row Factory
    如何让Jython自动加载一个Jar包
    跨计算机执行的几个方法
    Python 版 Instance Activator
  • 原文地址:https://www.cnblogs.com/net064/p/5664437.html
Copyright © 2011-2022 走看看