'以下内容用记事本保存为Move.frm,双击打开后F5运行
VERSION 5.00
Begin VB.Form Form1
Caption = "图片特技"
ClientHeight = 4890
ClientLeft = 2970
ClientTop = 630
ClientWidth = 8445
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4890
ScaleWidth = 8445
Begin VB.Timer Timer6
Interval = 1
Left = 6000
Top = 120
End
Begin VB.Timer Timer5
Interval = 1
Left = 5040
Top = 120
End
Begin VB.Timer Timer4
Interval = 1
Left = 4080
Top = 120
End
Begin VB.Timer Timer3
Interval = 1
Left = 3000
Top = 120
End
Begin VB.Timer Timer1
Interval = 1
Left = 1080
Top = 120
End
Begin VB.Timer Timer0
Interval = 1
Left = 240
Top = 120
End
Begin VB.Timer Timer2
Interval = 1
Left = 2040
Top = 120
End
Begin VB.PictureBox P2
AutoSize = -1 'True
Height = 3255
Left = 0
ScaleHeight = 3195
ScaleWidth = 7875
TabIndex = 1
Top = 600
Width = 7935
End
Begin VB.PictureBox P1
BackColor = &H80000000&
Height = 495
Left = 720
ScaleHeight = 435
ScaleWidth = 1635
TabIndex = 0
Top = 3960
Width = 1695
End
Begin VB.Menu 特技
Caption = " 推出 "
Index = 0
End
Begin VB.Menu 特技
Caption = " 拉近 "
Index = 1
End
Begin VB.Menu 特技
Caption = " 推拉 "
Index = 2
End
Begin VB.Menu 特技
Caption = " 百页窗 "
Index = 3
End
Begin VB.Menu 特技
Caption = " 马赛克 "
Index = 4
End
Begin VB.Menu 特技
Caption = " 拉幕 "
Index = 5
End
Begin VB.Menu 特技
Caption = " 滚动 "
Index = 6
End
Begin VB.Menu 停止
Caption = " 停止 "
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim W As Integer, H As Integer
Dim X As Integer, Y As Integer
Dim Back As Boolean
Private Sub Form_Load() '设置固定属性
P1.AutoSize = True
P1.Left = 0
P1.Top = 0
P2.AutoSize = True
P2.Visible = False
Reset
End Sub
Private Sub Reset() '重置有关变量及属性
Back = False
W = P2.Width
H = P2.Height
Form1.Width = W
Form1.Height = H + 700 '加菜单的高度
P1.Width = W
P1.Height = H
Stopped
End Sub
Private Sub Stopped() '停止所有定时器
Timer0.Enabled = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = False
Timer6.Enabled = False
End Sub
Private Sub 特技_Click(Index As Integer) '选择菜单
Static n As Integer
n = n + 1
If n > 4 Then n = 1 '四幅图片不断变换
P2.Picture = LoadPicture(App.Path & "\" & n & ".jpg")
Reset
P1.Cls
Select Case Index
Case 0 '推出
X = W / 2: Y = H / 2
Timer0.Enabled = True
Case 1 '拉近
X = 0: Y = 0
Timer1.Enabled = True
Case 2 '推拉
X = W / 2: Y = H / 2
Timer2.Enabled = True
Case 3 '百叶窗
X = 0: Y = 0
Timer3.Enabled = True
Case 4 '马赛克
Timer4.Enabled = True
Case 5 '拉幕
X = 0: Y = 0
Timer5.Enabled = True
Case 6 '滚动
X = 0
Timer6.Enabled = True
End Select
End Sub
Private Sub Timer0_Timer() '推出
X = X - W / 100: Y = Y - H / 100
If X <= 0 Or Y <= 0 Then Stopped
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
End Sub
Private Sub Timer1_Timer() '拉近
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
X = X + W / 100: Y = Y + H / 100 '初值为0
If X >= W / 2 Or Y >= H / 2 Then Stopped
End Sub
Private Sub Timer2_Timer() '推拉
If Back Then
X = X + W / 100: Y = Y + H / 100
If X >= W / 2 Or Y >= H / 2 Then Back = Not Back
Else
X = X - W / 100: Y = Y - H / 100
If X <= 0 Or Y <= 0 Then Back = Not Back: X = 0: Y = 0
End If
P1.PaintPicture P2.Picture, 0, 0, W, H, X, Y, W - 2 * X, H - 2 * Y
End Sub
Private Sub Timer3_Timer() '百叶窗
Dim i As Integer, j As Integer, m As Integer, n As Integer
m = W / 20: n = H / 20
X = X + W / 500: Y = Y + H / 500 '初值为0
If X >= m And Y >= n Then Stopped
For i = 0 To 20
For j = 0 To 20
P1.PaintPicture P2.Picture, i * m, j * n, , , i * m, j * n, X, Y
Next j, i
End Sub
Private Sub Timer4_Timer() '马赛克
Dim i As Integer, m As Integer, n As Integer, xx As Integer, yy As Integer
Static c As Integer
c = c + 1
If c > 100 Then P1.PaintPicture P2.Picture, 0, 0: c = 0
m = W / 100: n = H / 100
For i = 1 To 50 + c * 10
xx = Rnd * (W - m - 50)
yy = Rnd * (H - n - 50)
P1.PaintPicture P2.Picture, xx, yy, , , xx, yy, m, n
Next i
End Sub
Private Sub Timer5_Timer() '拉幕
X = X + W / 100: Y = Y + H / 100 '初值为0
P1.PaintPicture P2.Picture, W / 2 - X, 0, , , W / 2 - X, 0, 2 * X, H
If X > 0.51 * W Then Timer5.Enabled = False
End Sub
Private Sub Timer6_Timer() '滚动
X = X + W / 200 '初值为0
If X >= W Then Stopped
P1.PaintPicture P2.Picture, W - X, 0, , , 0, 0, X, H
End Sub
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength _
As Long, ByVal hwndCallback As Long) As Long