把picbox变成半透明 这个好像是不行了。不过可以让里面的图片半透明:
'This project requires two picture boxes
'Both picture boxes should contain a picture
Const AC_SRC_OVER = &H00
Private Type BLENDFUNCTION
BlendOp As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim BF As BLENDFUNCTION, lBF As Long
'Set the graphics mode to persistent
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
'API uses pixels
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
'set the parameters
With BF
.BlendOp = AC_SRC_OVER
.BlendFlags = 0
.SourceConstantAlpha = 128
.AlphaFormat = 0
End With
'copy the BLENDFUNCTION-structure to a Long
RtlMoveMemory lBF, BF, 4
'AlphaBlend the picture from Picture1 over the picture of Picture2
AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF
End Sub
'This project requires two picture boxes
'Both picture boxes should contain a picture
Const AC_SRC_OVER = &H00
Private Type BLENDFUNCTION
BlendOp As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim BF As BLENDFUNCTION, lBF As Long
'Set the graphics mode to persistent
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
'API uses pixels
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
'set the parameters
With BF
.BlendOp = AC_SRC_OVER
.BlendFlags = 0
.SourceConstantAlpha = 128
.AlphaFormat = 0
End With
'copy the BLENDFUNCTION-structure to a Long
RtlMoveMemory lBF, BF, 4
'AlphaBlend the picture from Picture1 over the picture of Picture2
AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货