VB中的PictureBox背景透明效果
VB中的PictureBox背景透明效果
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As L
ong, 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 Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Dim dx As Long, dy As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y A
s Single)
dx = X
dy = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y A
s Single)
If Button = vbLeftButton Then
Me.Move X + Me.Left - dx, Y + Me.Top - dy
End If
End Sub
Private Sub Timer1_Timer()
Picture1.Move X + Picture1.Left - dx, Y + Picture1.Top - dy
Picture1.Visible = False
Picture1.AutoRedraw = True
Me.Refresh
BitBlt Picture1.hDC, 0, 0, 300, 300, Me.hDC, (Picture1.Left) / Screen.Tw
ipsPerPixelX, (Picture1.Top) / Screen.TwipsPerPixelY, SRCCOPY
Picture1.Visible = True
Timer1.Enabled = False
End Sub