C # Windows API Application method based on FlashWindowEx to implement window Flicker _c# tutorial

Source: Internet
Author: User

The example in this article describes how the C # Windows API application is based on FlashWindowEx to implement window flicker. Share to everyone for your reference, specific as follows:

Windows API

Windows this multi-operating system, in addition to coordinating application execution, allocating memory, managing resources ... , it is also a very large service center, call the service center of the various services (each service is a function), can help the application to open windows, graphics, the use of peripheral devices, and so on, because these function services object is the application (application), so it is called Application programming Interface, abbreviation API function. The WIN32 API is the application programming interface of the Microsoft Windows 32-bit platform.

FlashWindowEx

function function: flashes the specified window. It does not change the activation state of the window.

Function Prototypes:

BOOL WINAPI FlashWindowEx (
__in pflashwinfo pfwi
);

Parameter: Pfwi pointer to Flashwinfo structure ...

Return value: Returns the specified window state before calling the FlashWindowEx function. If the window caption is active before the call, the return value is a value other than 0.

Ways to achieve window flicker

API Import

<summary>
///Flashing window
///</summary>
///<param name= "pwfi" > Window flashing information structure </param>
///<returns></returns>
[DllImport ("user32.dll")]
public static extern bool FlashWindowEx (ref flashwinfo PWFI);

Scintillation Type Enumeration Definition

<summary>
///Blinking type
///</summary> public
enum Flashtype:uint
{
  flashw_stop = 0,//stop blinking
  falshw_caption = 1,//flashing only the title
  Flashw_tray = 2,//Only flashing taskbar
  flashw_all = 3,//title and taskbar flashing simultaneously
  flashw_ PARAM1 = 4,
  flashw_param2 =
  Flashw_timer = Flashw_tray | FLASHW_PARAM1,//unconditional blinking taskbar until send Stop flag or window is activated, if not activated, stop highlighting
  Flashw_timernofg = Flashw_tray | Flash taskbar flashw_param2//Inactive until the STOP flag is sent or the form is activated, highlight after stop


Flashwinfo structure Definition

<summary>
///contains information about the number of flashing windows and flashing states that the system should have in a specified time
///</summary> public
struct Flashwinfo
{
  ///<summary>
  ///structure size
  ///</summary> public
  uint cbsize;
  <summary>
  ///Window handle
  ///</summary> public
  IntPtr hwnd to blink or stop;
  <summary>
  ///Flashing type
  ///</summary> public
  uint dwflags;
  <summary>
  ///Flashing window number
  ///</summary> public
  uint Ucount;
  <summary>
  ///window blink frequency, in milliseconds; If this value is 0, the blink frequency of the default icon
  ///</summary> public
  uint dwTimeOut;
}

Flashing Window Method Encapsulation

<summary>
///Flashing window
///</summary>
///<param name= "hWnd" > Window handle </param>
/ <param name= "type" > Flashing type </param>
///<returns></returns> public
static bool FlashWindowEx (IntPtr hWnd, Flashtype type)
{
  Flashwinfo finfo = new Flashwinfo ();
  Finfo.cbsize = Convert.touint32 (marshal.sizeof (Finfo));
  Finfo.hwnd = hwnd;//The handle of the window to blink, which can be open or minimized
  Finfo.dwflags = (UINT) type;//blinking type
  Finfo.ucount = The number of uint32.maxvalue;//flashing windows
  finfo.dwtimeout = 0;//The frequency of the window flashing, in milliseconds, or 0 for the default icon's Blink frequency return
  FlashWindowEx ( Ref finfo);
}

Read more about C # Interested readers can view the site topics: "C # form Operation Tips Summary", "C # Data structure and algorithm tutorial", "C # Common control usage Tutorial", "C # object-oriented Program design Introductory Course" and "C # Programming Thread Usage Skills Summary"

I hope this article will help you with C # programming.

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.