BitBlt问题请教
在VB中,两个PictureBox,现在需要从一个PictureBox中使用BitBlt函数把图片一点点复制到另外一个PictureBox中去。
现在的问题是两个PictureBox完全重叠在一起的时候
(有源图片的PictureBox在下面。要动态展示图片的PictureBox在上边)
使用BitBlt函数起不了作用了?
[解决办法]
Option ExplicitPrivate Declare Function BitBlt Lib "gdi32.dll" (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 LongPrivate Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)Private Const SRCCOPY As Long = &HCC0020'关门特技Private Sub Command1_Click() Dim hDc1 As Long, hDC2 As Long Dim W As Long, H As Long, i As Long Picture2.Cls On Error GoTo Lhandle hDc1 = Picture1.hDC hDC2 = Picture2.hDC W = Picture1.ScaleWidth H = Picture1.ScaleHeight For i = 0 To (W / 2) + 1 BitBlt hDC2, i, 0, 1, H, hDc1, i, 0, SRCCOPY BitBlt hDC2, W - i, 0, W, H, hDc1, W - i, 0, SRCCOPY Sleep (10) NextLhandle: End SubPrivate Sub Form_Load() Picture1.Visible = False Picture2.Visible = True Picture1.AutoRedraw = True Picture2.AutoRedraw = False Picture1.Picture = LoadPicture("c:\cccc.jpg")'事先加载一张图片 Picture1.ScaleMode = 3 Picture2.ScaleMode = 3 Picture2.Left = Picture1.Left Picture2.Top = Picture1.Top Picture2.Width = Picture1.Width Picture2.Height = Picture1.HeightEnd Sub
[解决办法]
http://download.csdn.net/source/1371365