AnimateWindow

主要是使窗口具有動態效果,通常是動態顯示公司的商標或者公司的宣傳材料。

 

函數聲明(winuser.h)

#if(WINVER >= 0x0500)

WINUSERAPI

BOOL

WINAPI

AnimateWindow(

   __in HWND hWnd,              // 窗口的句柄

   __in DWORD dwTime,        // 動態出現的時間,單位:milliseconds

   __in DWORD dwFlags);     // 顯示效果的標誌設置

#endif /* WINVER >= 0x0500*/

參數

dwFlags:

AW_SLIDE Uses slide animation. By default, roll animation is used. This flag is ignored when used with the AW_CENTER flag.
AW_ACTIVATE Activates the window. Do not use this flag with AW_HIDE.
AW_BLEND Uses a fade effect. This flag can be used only if hwnd is a top-level window.
AW_HIDE Hides the window. By default, the window is shown.
AW_CENTER Makes the window appear to collapse inward if the AW_HIDE flag is used or expand outward if the AW_HIDE flag is not used.
AW_HOR_POSITIVE Animate the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag.
AW_HOR_NEGATIVE Animate the window from right to left. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag.
AW_VER_POSITIVE Animate the window from top to bottom. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag.
AW_VER_NEGATIVE Animate the window from bottom to top. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag.

返回值

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. The function will fail in the following situations:

  • The window uses the window region.
  • The window is already visible and you are trying to show the window.
  • The window is already hidden and you are trying to hide the window

 

但是在使用的過程中通常會遇到編譯出錯的情況,如:AnimateWindow未聲明等,原因是這個函數的聲明中有#if(WINVER >= 0x0500),解決方法有很多種:

1、在StdAfx.h靠前的地方重新定義

      加上#undef  WINVER 
            #define  WINVER   0x500

2、修改Winuser.h中的#if(WINVER >= 0x0500),改爲#if(WINVER >= 0x0400)

關於WINVER

Windows 95  and  Windows NT 4.0       WINVER=0x0400       
Windows 98  and  Windows NT 4.0       _WIN32_WINDOWS=0x0410   and   WINVER=0x0400     
Windows NT 4.0                                    _WIN32_WINNT=0x0400   and   WINVER=0x0400     
Windows   2000                                    _WIN32_WINNT=0x0500   and   WINVER=0x0500     
Windows   Me                                       _WIN32_WINDOWS=0x0490    
Windows   XP and  Windows .NET Server            _WIN32_WINNT=0x0501   and   WINVER=0x0501     
Internet   Explorer   3.0,  3.01,  3.02                 _WIN32_IE=0x0300    
Internet   Explorer   4.0                                   _WIN32_IE=0x0400    
Internet   Explorer   4.01                                 _WIN32_IE=0x0401    
Internet   Explorer   5.0,   5.0a,   5.0b               _WIN32_IE=0x0500    
Internet   Explorer   5.01,   5.5                         _WIN32_IE=0x0501    
Internet   Explorer   6.0                                   _WIN32_IE=0x0560   or   _WIN32_IE=0x0600

 

注意

使用AnimateWindow來進行淡出時,此時窗口收不到鼠標消息了,如果你有需求:在窗口淡出即將消失時,如果鼠標移上去,窗口恢復正常顯示,並且不消失。使用AnimateWindow是沒辦法實現的,只能使用其它方法。

不過還是有一點沒搞明白,Windows XP的WINVER=0x0501,爲什麼使用AnimateWindow的時候還要重新定義WINVER

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章