'添一个Timer控件 Option ExplicitPrivate Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2 Private Const LWA_COLORKEY = &H1Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDim lR As Long'将扣去窗口中的指定色 Public Sub TransparenceWindow(hWnd As Long, ByVal lTransparenceColor As Long) Dim lR As Long On Error GoTo Err1 lR = GetWindowLong(hWnd, GWL_EXSTYLE) lR = lR Or WS_EX_LAYERED SetWindowLong hWnd, GWL_EXSTYLE, lR SetLayeredWindowAttributes hWnd, lTransparenceColor, 0, LWA_COLORKEY '将扣去窗口中的蓝色 Exit Sub Err1: End SubPrivate Sub Form_Load() Me.ForeColor = vbBlue Me.FillColor = vbBlue Me.BackColor = vbRed End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Unload Me End SubPrivate Sub Timer1_Timer() lR = (lR + 1) Mod 100 Me.Circle (150, 150), lR Me.TransparenceWindow Me.hWnd, vbRed End Sub
Option ExplicitPrivate Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDim lR As Long'将扣去窗口中的指定色
Public Sub TransparenceWindow(hWnd As Long, ByVal lTransparenceColor As Long)
Dim lR As Long
On Error GoTo Err1 lR = GetWindowLong(hWnd, GWL_EXSTYLE) lR = lR Or WS_EX_LAYERED SetWindowLong hWnd, GWL_EXSTYLE, lR SetLayeredWindowAttributes hWnd, lTransparenceColor, 0, LWA_COLORKEY '将扣去窗口中的蓝色
Exit Sub
Err1:
End SubPrivate Sub Form_Load()
Me.ForeColor = vbBlue
Me.FillColor = vbBlue
Me.BackColor = vbRed
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Unload Me
End SubPrivate Sub Timer1_Timer()
lR = (lR + 1) Mod 100
Me.Circle (150, 150), lR
Me.TransparenceWindow Me.hWnd, vbRed
End Sub