热门文章 | 热门软件| 热门源码 | 热门电影 | 知识库 | 联系我们
软件 源码 教程 影视 健康 招聘
  HTML | JavaScript | ASP | PHP | JSP | NET | VB | VC | VF | Windows | Linux | Mysql | Mssql | Oracle | Struts 
当前位置: 创世纪计算机资源网 -> 文章频道 ->vb 
站内搜索:
雨滴式显示图片
作者:佚名 来源:不详 整理日期:2007-4-13
需求两个PictureBox(picture1中加载一张图片),一个Command按键
Option Explicit
Private 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
Private Declare Function CreateCompatibleDC Lib "gdi32" _
                (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" _
                (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Const SRCCOPY = &HCC0020

Private Sub Command1_Click()
Dim i As Long
Dim j As Long
Dim height5 As Long, width5 As Long
Dim hMemDc As Long
转换为Pixel度量值
height5 = ScaleY(Picture1.Picture.Height, vbHimetric, vbPixels)
If height5 > Picture2.ScaleHeight Then
   height5 = Picture2.ScaleHeight
End If
转换为Pixel度量值
width5 = ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels)
If width5 > Picture2.ScaleWidth Then
   width5 = Picture2.ScaleWidth
End If
Create Memory DC
hMemDc = CreateCompatibleDC(Picture2.hdc)
将Picture1的BitMap图指定给hMemDc
Call SelectObject(hMemDc, Picture1.Picture.Handle)
For i = height5 To 1 Step -1
    Call BitBlt(Picture2.hdc, 0, i, width5, 1, _
                hMemDc, 0, i, SRCCOPY)
    For j = i - 1 To 1 Step -1
        Call BitBlt(Picture2.hdc, 0, j, width5, 1, _
                hMemDc, 0, i, SRCCOPY)
    Next j
Next
Call DeleteDC(hMemDc)
End Sub

Private Sub Form_Load()
Dim i As Long
Picture2.ScaleMode = 3 设定成Pixel的度量单位
End Sub

相关文章