http://blog.sina.com.cn/s/blog_455245fc01000a42.html
法如下:
/**************************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