百叶窗效果
实现步骤:
1.建立一个新项目,将其命名为Demo5.vbp。
2.增加模块Demo5.bas,在Demo5.bas中加入如下代码:
Public Const SRCCOPY = &HCC0020
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
3.在窗体的声明部分加入代码:
Dim h, w As Integer
4.在窗体的Form_Load处理程序中加入代码:
Private Sub Form_Load()
Picture1.Move 0, 0
Picture2.Move 0, 0
h = Picture1.ScaleHeight
w = Picture1.ScaleWidth
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
End Sub
5.在窗体的Command1_Click处理代码中:
Private Sub Command1_Click()
Dim i, j, g As Integer
Picture2.Cls
For i = 0 To 50
For j = i To w Step 50
BitBlt Picture2.hDC, j, 0, 1, h, Picture1.hDC, j, 0, SRCCOPY
For g = 0 To 500
Next g
Next j
Next i
End Sub
6.在窗体的Command2_Click的处理程序中:
Private Sub Command2_Click()
Dim i, j, g As Integer
Picture2.Cls
For i = 0 To 50
For j = i To w Step 50
BitBlt Picture2.hDC, 0, j, w, 1, Picture1.hDC, 0, j, SRCCOPY
For g = 0 To 500
Next g
Next j
Next i
End Sub
7.在窗体的Picture1_Resize的处理程序中加入代码:
Private Sub Picture1_Resize()
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
End Sub
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073