Option Explicit
'*****************************************透明窗体的API
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex 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 Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cX As Long, ByVal cY As Long, ByVal wFlags 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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
Const LWA_COLORKEY = &H1
'********************************************************************
Dim rtn&, transcolor&
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
ranscolor = &HFF0000
Me.BorderStyle = 0: Me.Caption = "": Me.BackColor = transcolor
Me.Move (Screen.Width - Me.Width) , (Screen.Height - Me.Height)
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn SetLayeredWindowAttributes hwnd, transcolor, 255, LWA_COLORKEY Or LWA_ALPHA '将扣去窗口中的蓝色背景
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Form1 = Nothing
End
End Sub
Private Sub Label1_dblClick()
End
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Date & "-" & Time
End Sub
@一蓑烟雨柒落
透明时钟 vb代码