使任务栏上窗口按钮闪烁(FlashWindowEX)

API中提供了两个函数:FlashWindow、FlashWindowEx。

FlashWindow函数原型声明如下:

BOOL FlashWindow(
        HWND hWnd, // handle to window
        BOOL bInvert // flash status
        );

第一个参数 hWnd 是要做闪烁的窗体的句柄。
第二个参数 bInvert 参数的含义是--使窗体闪烁或返回原先的一个状态(这里指是否激活的
状态)。如果参数设定的是 True 则窗体的状态从一个状态改变成另一个状态(从激活到非激活状态
或反之)。如果是设定的 False 则窗体返回原来的状态(基本上和设定为 True 的过程相反)。如
果一个窗体是最小化状态,而且参数指定为 True,以上提到的效果会在任务栏的按钮上表现出来。
如果设定的是 False 则任务栏上的按钮会变成非激活状态,但是不会以颜色的变化而显示出来(原
来什么样现在还什么样,不做闪烁动作向用户反馈)。
  
  返回值是返回在调用本函数之前的窗体的状态。如果窗体之前是激活状态,返回非零值,如果是
非激活状态返回零。

Remarks
Flashing a window means changing the appearance of its caption bar as if the w
indow were changing from inactive to active status, or vice versa. (An inactive
caption bar changes to an active caption bar; an active caption bar changes to a
n inactive caption bar.) Typically, a window is flashed to inform the user that
the window requires attention but that it does not currently have the keyboard f
ocus.

The FlashWindow function flashes the window only once; for repeated flashing,
the application should create a system timer.

======================================================================================

FlashWindowEx函数原型声明如下:

BOOL FlashWindowEx(
         PFLASHWINFO pfwi // flash status information
         );

本函数只有一个参数,是一个结构体指针。指向结构体 FLASHWINFO。
FLASHWINFO 结构体定义如下:

typedef struct {
UINT cbSize;          //本结构的大小
HWND hwnd;           //将做闪烁窗体的句柄 
DWORD dwFlags;          //闪烁的方式  
UINT uCount;          //闪烁次数
DWORD dwTimeout;         //闪烁的频率 
} FLASHWINFO, *PFLASHWINFO;

  个参数具体说明如下:
  cbSize: 同上;  (在DELPHI中使用SizeOf()函数来取得)
  hwnd : 同上;  (可使用FindWindw函数来取得)
  dwFlags: 同上,具体取值如下:
FLASHW_STOP    --停止闪烁,系统存储窗体的原始状态(激活与否)
FLASHW_CAPTION  --闪烁标题(Caption)
FLASHW_TRAY    --闪烁任务栏按钮
FLASHW_ALL    --闪烁标题和任务栏按钮,等于设置FLASHW_CAPTION|FLASHW_TRAY
           的效果。
FLASHW_TIMER   --不断的闪烁,直到 FLASHW_STOP 标志被设置 
FLASHW_TIMERNOFG --不断闪烁,直到窗体变成当前窗体
uCount: 同上;
dwTimeout: 同上;

适用平台:
Windows NT/2000/XP: Included in Windows 2000 and later.
   Windows 95/98/Me: Included in Windows 98 and later.
   Header: Declared in Winuser.h; include Windows.h.

posted on 2014-09-19 22:45  云之灵  阅读(920)  评论(0编辑  收藏  举报