VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 百叶窗效果
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8552, 日期:2001-06-14
百叶窗效果


  实现步骤:

  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