Option Explicit Private Declare Function TransparentBlt Lib “msimg32” _ (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 crTransparent As Long) As Long Private Declare Function GetPixel Lib “gdi32” (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
‘调用示例 ‘添加一个 PictureBox,命名为 picSource,并加载图片 Dim TransparentColor As Long TransparentColor = GetPixel(picSource.hdc, 0, 0) ‘选择左上角(0,0)的颜色为屏蔽色 ‘thne simply draw with the transparent color equal to the value we found above With picSource TransparentBlt Me.hdc, 0, 0, .ScaleWidth, .ScaleHeight, .hdc, 0, 0, .ScaleWidth, .ScaleHeight, TransparentColor End With Me.Refresh