我在窗体内放了5幅图片,我想让它们淡出淡入循环显示,不知道代码该如何写,麻烦给解决一下;写下原码
解决方案 »
- 用VB进行开发时,不同的SQL数据表是如何进行关联的?
- OpenProcess为什么总是返回0
- 请问:如何对字符串进行分割,不区分大小写。
- 【急】求WSOCK32.DLL中函数的API声明,和简单的相关例程,多谢!!!
- 求高手指教:简单的图像识别问题
- 如何根据一个数据集得到另一数据集
- 在打开一个程序的时候不能够编译执行,帮忙看看报的错,
- 关于ftp文件的问题,急、急、急、急、急!!!!!
- 有谁可以告诉我怎样用MAPI获得邮件的附件,或者用其它方法也可以
- 我是菜鸟,高分征集窗体特效源码~!
- vb winsock发送数组中的数据可以只发送其中的一部分吗?
- 解决控件全屏居中的问题?请高手帮忙 100分
ByVal hdcDest As Long, _
ByVal nXOriginDest As Long, _
ByVal nYOriginDest As Long, _
ByVal nWidthDest As Long, _
ByVal nHeightDest As Long, _
ByVal hdcSrc As Long, _
ByVal nXOriginSrc As Long, _
ByVal nYOriginSrc As Long, _
ByVal nWidthSrc As Long, _
ByVal nHeightSrc As Long, _
ByVal BLENDFUNCTION As Long) As Boolean
Const AC_SRC_OVER = &H0
Const AC_SRC_ALPHA = &H1
Private Type BLENDFUNCTION
BlendOP As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
Private Declare Sub Sleep Lib "kernel32" _
( _
ByVal dwMilliseconds As Long _
)
'Sleep为延时函数以毫秒为单位指定等待的时间
Dim sBlendFunction As BLENDFUNCTION
Dim LnBlendPtr As Long
Private Sub Form_Load()
Timer1.Interval = 2000
sBlendFunction.BlendOP = AC_SRC_OVER
sBlendFunction.BlendFlags = 0
sBlendFunction.AlphaFormat = 0
FrmTs.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
'设置Form、Picture1和Picture2的标志单位为像素
Picture1.AutoRedraw = False
Picture2.AutoRedraw = False
Picture1.Picture = LoadPicture(App.Path + "\1.bmp")
End SubPrivate Sub Timer1_Timer()
Dim LnBlendPtr As Long
Static j As Integer
j = j + 1
If j = 1 Then
Picture1.Picture = LoadPicture(App.Path + "\fore.bmp")
trtc
ElseIf j = 2 Then
j = j - 2
Picture1.Picture = LoadPicture(App.Path + "\1.bmp")
trtc
End If
End SubPublic Function trtc()
'淡入效果
Picture2.Cls
For i = 0 To 50
sBlendFunction.SourceConstantAlpha = i * 5
CopyMemory LnBlendPtr, sBlendFunction, 4
AlphaBlend Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, _
Picture1.hDC, 0, 0, Picture1.Width, Picture1.Height, _
LnBlendPtr
Sleep (50)
DoEvents
Next
'淡出效果
Picture2.Cls
For i = 0 To 10
sBlendFunction.SourceConstantAlpha = 250 - i * 25
CopyMemory LnBlendPtr, sBlendFunction, 4
AlphaBlend Picture2.hDC, 0, 0, Picture2.Width, _
Picture2.Height, Picture1.hDC, 0, 0, Picture1.Width, Picture1.Height, _
LnBlendPtr
Sleep (50)
Picture2.Refresh
DoEvents
Next
End Function
实现特效,帮忙再给看看吧
Option Explicit
Dim w, h As Single
'w和h分别记录图片的宽度和高度
Dim x, y As Single
'x和y分别为取图位置的X坐标和Y坐标
'或者也可以说成是所取区域的宽度和高度
Dim b As Boolean
Dim i, m, n, j As IntegerPrivate Sub Reset()
w = Picture1.Width
h = Picture1.Height
'保存图片的宽度和高度
Picture2.Width = w
Picture2.Height = h
'根据图片设置Picture2的宽度和高度
'重新设置List1控件的位置
Me.Width = w + 700
'设置窗口的宽度
Me.Height = h + 700
'设置窗口的高度
'注意留出菜单的高度
b = False
End SubPrivate Sub Form_Load()
Picture1.Left = 0
Picture1.Top = 0
'使Picture1位于窗口的左上角
Picture1.AutoSize = True
'使Picture1能够根据图片自动更改自己的宽度和高度
Picture1.Visible = False
'隐藏Picture1
Picture1.Picture = LoadPicture(App.Path + "\water.jpg")
'在Picture1中显示一幅图片
Picture2.Left = 0
Picture2.Top = 0
Reset
Timer1.Interval = 50
End SubPrivate Sub Timer1_Timer()
'网格效果
m = w / 20
n = h / 20
x = x + w / 200
y = y + h / 200
If x > m Then
Picture2.Picture = Picture1.Picture
End If
For i = 0 To 20
For j = 0 To 20
Picture2.PaintPicture Picture1.Picture, i * m, j * n, , , i * m, j * n, x, y
Next j, iEnd Sub
通过一个循环,不断加强或减弱Alpha的程度,可以达到淡入淡出的渲染效果,实际编写起来可能会麻烦一点,可以在网上找实例程序