C# WindowsAPI application FlashWindowEx - Detailed explanation of the method of realizing window flashing

黄舟
Release: 2017-03-11 13:27:49
Original
2881 people have browsed it


Windows API


In addition to coordinating the execution of applications, allocating memory, and managing resources, Windows, a multi-operating system, is also a large The service center calls various services of this service center (each service is a function), which can help the application to open windows, draw graphics, use peripheral devices, etc., because the objects served by these functions are applications (Application ), so it is called Application Programming Interface, or API function for short. WIN32 API is the application programming interface of the Microsoft Windows 32-bit platform.

FlashWindowEx


Function: Flash the specified window. It does not change the activation state of the window.
Function prototype: BOOL WINAPI FlashWindowEx(
 __in PFLASHWINFO pfwi
 );
Parameters: pfwi is a pointer to the FLASHWINFO structure. .
Return value: Returns the specified window state before calling the FlashWindowEx function. If the window title was active before the call, the return value is non-zero.

Method to implement window flashing


API import

///  /// 闪烁窗口 ///  /// 窗口闪烁信息结构 ///  [DllImport("user32.dll")] public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
Copy after login

Flash type enumeration definition

///  /// 闪烁类型 ///  public enum flashType : uint { FLASHW_STOP = 0, //停止闪烁 FALSHW_CAPTION = 1, //只闪烁标题 FLASHW_TRAY = 2, //只闪烁任务栏 FLASHW_ALL = 3, //标题和任务栏同时闪烁 FLASHW_PARAM1 = 4, FLASHW_PARAM2 = 12, FLASHW_TIMER = FLASHW_TRAY | FLASHW_PARAM1, //无条件闪烁任务栏直到发送停止标志或者窗口被激活,如果未激活,停止时高亮 FLASHW_TIMERNOFG = FLASHW_TRAY | FLASHW_PARAM2 //未激活时闪烁任务栏直到发送停止标志或者窗体被激活,停止后高亮 }
Copy after login

FLASHWINFO structure definition

///  /// 包含系统应在指定时间内闪烁窗口次数和闪烁状态的信息 ///  public struct FLASHWINFO { ///  /// 结构大小 ///  public uint cbSize; ///  /// 要闪烁或停止的窗口句柄 ///  public IntPtr hwnd; ///  /// 闪烁的类型 ///  public uint dwFlags; ///  /// 闪烁窗口的次数 ///  public uint uCount; ///  /// 窗口闪烁的频度,毫秒为单位;若该值为0,则为默认图标的闪烁频度 ///  public uint dwTimeout; }
Copy after login

Flash window method encapsulation

///  /// 闪烁窗口 ///  /// 窗口句柄 /// 闪烁类型 ///  public static bool FlashWindowEx(IntPtr hWnd, flashType type) { FLASHWINFO fInfo = new FLASHWINFO(); fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); fInfo.hwnd = hWnd;//要闪烁的窗口的句柄,该窗口可以是打开的或最小化的 fInfo.dwFlags = (uint)type;//闪烁的类型 fInfo.uCount = UInt32.MaxValue;//闪烁窗口的次数 fInfo.dwTimeout = 0; //窗口闪烁的频度,毫秒为单位;若该值为0,则为默认图标的闪烁频度 return FlashWindowEx(ref fInfo); }
Copy after login

The above is the detailed content of C# WindowsAPI application FlashWindowEx - Detailed explanation of the method of realizing window flashing. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!