Design a flashing form

Source: Internet
Author: User

1. Overview

When the QQ dialog box receives a message, if the dialog box is not the active form, the dialog box flashes to prompt the user for a new message that needs to be read, and this is the form in which the Flash form is implemented.

2. Design details

. NET does not provide the classes and methods that implement the flicker of the form directly, it needs to call the Windows API function FlashWindow () implementation. The function is declared in C # as follows:

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

This function can implement a form flicker, but only once, if you want to achieve multiple flashes, you can use the Timer Timer component implementation.

Note: When using Windows API functions in Windows applications, namespace System.Runtime.InteropServices must be introduced;

3. Form Design

4. Program code

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 usingSystem.Runtime.InteropServices;Ten  One namespaceKaifafanli A { -      -      Public Partial classForm6:form the     { -[DllImport ("User32")] -         Private Static extern LongFlashWindow (INTPTR handle,BOOLBinvert); -          PublicFORM6 () +         { - InitializeComponent (); +         } A  at         Private voidTimer1_Tick (Objectsender, EventArgs e) -         { -FlashWindow ( This. Handle,true); -         } -  -         Private voidButton1_Click (Objectsender, EventArgs e) in         { -              This. timer1. Enabled =true; to         } +  -         Private voidButton2_Click (Objectsender, EventArgs e) the         { *              This. timer1. Enabled =false; $         }Panax Notoginseng  -     } the}
View Code

Design a flashing form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.