1,486
社区成员
发帖
与我相关
我的任务
分享
'Example Name:GdiTransparentBlt
'This project needs 2 pictureboxes
'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
Private Declare Function GdiTransparentBlt Lib "gdi32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Picture1.AutoSize = True
'API uses pixels
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
End Sub
Private Sub Picture2_Paint()
'If we don't call DoEvents first, our transparent image will be completely wrong
DoEvents
GdiTransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
End Sub