AnimateWindow 來美化你的對話框

AnimateWindow 來美化你的對話框(淡入淡出,自動上升下降) (2007-08-20 12:47:12)

方法如下:

/**************************AnimateWindow()**************************/
 

#define AW_HOR_POSITIVE             0x00000001
#define AW_HOR_NEGATIVE             0x00000002
#define AW_VER_POSITIVE             0x00000004
#define AW_VER_NEGATIVE             0x00000008
#define AW_CENTER                   0x00000010
#define AW_HIDE                     0x00010000
#define AW_ACTIVATE                 0x00020000
#define AW_SLIDE                    0x00040000
#define AW_BLEND                    0x00080000

void CPageDlg::OnClose()    //實現淡出功能
{
 //定義AnimateWindow的函數指針
 typedef UINT (CALLBACK* LPFUN)(HWND hwnd, DWORD dwTime,DWORD dwFlags);
 LPFUN pp;
 HINSTANCE hInst=::LoadLibrary("user32.dll");

 if(hInst)
 {
  pp = (LPFUN)::GetProcAddress(hInst, "AnimateWindow" );
  pp(GetSafeHwnd(), 300,AW_BLEND|AW_HIDE);   // 紅色的是動畫類型
  ::FreeLibrary(hInst );                     //綠色的是時間
 }                                           //下同

CDialog::OnClose();
}


同理:

void CHipDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
 CDialog::OnShowWindow(bShow, nStatus);   //顯示時不過不是淡入,而是滾動
                                          //主要是表現下參數的不同
 // TODO: Add your message handler code here
  //定義AnimateWindow的函數指針
 typedef UINT (CALLBACK* LPFUN)(HWND hwnd, DWORD dwTime,DWORD dwFlags);
 LPFUN pp;
 HINSTANCE hInst=::LoadLibrary("user32.dll");

 if(hInst)
 {
  pp = (LPFUN)::GetProcAddress(hInst, "AnimateWindow" );
  pp(GetSafeHwnd(), 500, AW_SLIDE|AW_VER_NEGATIVE);
  ::FreeLibrary(hInst );
 }

}

 

 

關於參數問題:

函數原型:BOOL   AnimateWindow(HWND   hWnd,DWORD   dwTime,DWORD   dwFlags)。    
   
  函數功能:該函數能在顯示與隱藏窗口時產生兩種特殊類型的動畫效果:滾動動畫和滑動動畫。    
   
  參數含義:        
  hWnd:指定產生動畫的窗口的句柄。    
  dwTime:指明動畫持續的時間(以微秒計),完成一個動畫的標準時間爲200微秒。    
  dwFags:指定動畫類型。這個參數可以是一個或多個下列標誌的組合。標誌描述:    
  AW_SLIDE:使用滑動類型。缺省則爲滾動動畫類型。當使用AW_CENTER標誌時,這個標誌就被忽略。    
  AW_ACTIVATE:激活窗口。在使用了AW_HIDE標誌後不能使用這個標誌。    
  AW_BLEND:實現淡出效果。只有當hWnd爲頂層窗口的時候纔可以使用此標誌。    
  AW_HIDE:隱藏窗口,缺省則顯示窗口。    
  AW_CENTER:若使用了AW_HIDE標誌,則使窗口向內重疊,即收縮窗口;若未使用AW_HIDE標誌,則使窗口向外擴展,即展開窗口。    
  AW_HOR_POSITIVE:自左向右顯示窗口。該標誌可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標誌時,該標誌將被忽略。    
  AW_VER_POSITIVE:自頂向下顯示窗口。該標誌可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標誌時,該標誌將被忽略。    
  AW_VER_NEGATIVE:自下向上顯示窗口。該標誌可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標誌時,該標誌將被忽略。    
   
     
  返回值:如果函數成功,返回值爲非零;如果函數失敗,返回值爲零。在下列情況下函數將失敗:    
   
  窗口使用了窗口邊界;窗口已經可見仍要顯示窗口;窗口已經隱藏仍要隱藏窗口
 
$hwnd = GUICreate("Animate Window", 300, 300)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
GUISetState()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040001);slide in from left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050002);slide out to left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040002);slide in from right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050001);slide out to right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040004);slide-in from top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050008);slide-out to top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040008);slide-in from bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050004);slide-out to bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040005);diag slide-in from Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x0005000a);diag slide-out to Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040006);diag slide-in from Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050009);diag slide-out to Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040009);diag slide-in from Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050006);diag slide-out to Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x0004000a);diag slide-in from Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050005);diag slide-out to Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040010);explode
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050010);implode
發佈了12 篇原創文章 · 獲贊 9 · 訪問量 35萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章