declare function AnimateWindow Lib "user32" (ByVal hwnd as long,ByVal dwTime as long,ByVal dwFlags as Long)as long Const AW_HOR_POSITIVE=&H1 '从左到右 Const AW_HOR_NEGATIVE=&H2 '从右到左 Const AW_VER_POSITIVE=&H4 '从上到下 Const AW_VER_NEGATIVE=&H8 '从下到上 Const AW_CENTER=&H10 '从中间开始 Const AW_HIDE=&H10000 '卸载时使用 Const AW_ACTIVATE=&H20000 '打开时使用 Const AW_SLIDE=&H40000 '与前四中组合拉出样式 Const AW_BLEND=&H80000 '谈入谈出常量可以相互组合使用,具体条用例子如下: private sub form_load() AnimateWindow hwnd,1000,aw_blend+aw_activate ‘1000为动态窗口的时间,单位为毫秒 end sub
AnimateWindow 只有Win2000才有
AnimateWindow 我试过了,不符合我的要求。它只提供了自身的出现的效果,而不是象窗体缩小到任务栏时,窗体由大到小移动到指定方向的动态效果我找到一个"user32"中的API函数:"DrawAnimatedRects",好象是实现这样效果的,但不知怎么用,谁能帮帮忙示范一下?该函数说明如下:Declare Function DrawAnimatedRects Lib "user32" Alias "DrawAnimatedRects" (ByVal hwnd As Long, ByVal idAni As Long, lprcFrom As Rect, lprcTo As Rect) As Long 说明 在lprcFrom和lprcTo之间描绘一系列动态矩形 返回值 Long,非零表示成功,零表示失败 参数表 参数 类型及说明 hwnd Long,要在其中描绘矩形的窗口。如设为零,表示以桌面为背景 idAni Long,windows 95要设为0 lprcFrom Rect,原始矩形 lprcTo Rect,目标矩形 注解 我的理解——这个函数用于在窗口缩放时产生动画效果
我直接用下面的方法效果也不错啊, 缩小时相反. Private Sub Command1_Click()Form1.Show Do While i <= 10 Form1.Move Screen.Width - (Screen.Width - formLeft) / 10 * i, Screen.Height - (Screen.Height - formTop) / 10 * i, formWidth * i / 10, formHeight * i / 10 Form1.Visible = True Form1.Refresh i = i + 1 Loop Form1.WindowState = 0End Sub
我找到DrawAnimatedRects的用法啦,确实是我需要的效果,非常棒。大家有兴趣不妨也试一试。我是在“http://www.allapi.net”上找到的,这是一个很不错的API函数站点,不仅有函数的说明,还有详细的使用例子,很不错,建议大家都收藏到自己的收藏夹里。下面的例子就来自http://www.allapi.netConst IDANI_OPEN = &H1 Const IDANI_CLOSE = &H2 Const IDANI_CAPTION = &H3 Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function SetRect Lib "User32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function DrawAnimatedRects Lib "User32" (ByVal hWnd As Long, ByVal idAni As Long, lprcFrom As RECT, lprcTo As RECT) As LongPrivate Sub Form_Load() 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: [email protected] Dim rSource As RECT, rDest As RECT, ScreenWidth As Long, ScreenHeight As Long 'retrieve the screen width and height ScreenWidth = Screen.Width / Screen.TwipsPerPixelX ScreenHeight = Screen.Height / Screen.TwipsPerPixelY 'set the source and destination rects SetRect rSource, ScreenWidth, ScreenHeight, ScreenWidth, ScreenHeight SetRect rDest, 0, 0, 200, 200 'animate DrawAnimatedRects Me.hWnd, IDANI_CLOSE Or IDANI_CAPTION, rSource, rDest 'set the form's position Me.Move 0, 0, 200 * Screen.TwipsPerPixelX, 200 * Screen.TwipsPerPixelY End Sub
可以查查msdn
Const AW_HOR_POSITIVE=&H1 '从左到右
Const AW_HOR_NEGATIVE=&H2 '从右到左
Const AW_VER_POSITIVE=&H4 '从上到下
Const AW_VER_NEGATIVE=&H8 '从下到上
Const AW_CENTER=&H10 '从中间开始
Const AW_HIDE=&H10000 '卸载时使用
Const AW_ACTIVATE=&H20000 '打开时使用
Const AW_SLIDE=&H40000 '与前四中组合拉出样式
Const AW_BLEND=&H80000 '谈入谈出常量可以相互组合使用,具体条用例子如下:
private sub form_load()
AnimateWindow hwnd,1000,aw_blend+aw_activate ‘1000为动态窗口的时间,单位为毫秒
end sub
说明
在lprcFrom和lprcTo之间描绘一系列动态矩形
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
hwnd Long,要在其中描绘矩形的窗口。如设为零,表示以桌面为背景
idAni Long,windows 95要设为0
lprcFrom Rect,原始矩形
lprcTo Rect,目标矩形
注解
我的理解——这个函数用于在窗口缩放时产生动画效果
Private Sub Command1_Click()Form1.Show
Do While i <= 10
Form1.Move Screen.Width - (Screen.Width - formLeft) / 10 * i, Screen.Height - (Screen.Height - formTop) / 10 * i, formWidth * i / 10, formHeight * i / 10
Form1.Visible = True
Form1.Refresh
i = i + 1
Loop
Form1.WindowState = 0End Sub
Const IDANI_CLOSE = &H2
Const IDANI_CAPTION = &H3
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SetRect Lib "User32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DrawAnimatedRects Lib "User32" (ByVal hWnd As Long, ByVal idAni As Long, lprcFrom As RECT, lprcTo As RECT) As LongPrivate Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim rSource As RECT, rDest As RECT, ScreenWidth As Long, ScreenHeight As Long
'retrieve the screen width and height
ScreenWidth = Screen.Width / Screen.TwipsPerPixelX
ScreenHeight = Screen.Height / Screen.TwipsPerPixelY
'set the source and destination rects
SetRect rSource, ScreenWidth, ScreenHeight, ScreenWidth, ScreenHeight
SetRect rDest, 0, 0, 200, 200
'animate
DrawAnimatedRects Me.hWnd, IDANI_CLOSE Or IDANI_CAPTION, rSource, rDest
'set the form's position
Me.Move 0, 0, 200 * Screen.TwipsPerPixelX, 200 * Screen.TwipsPerPixelY
End Sub