7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
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)
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_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const LWA_COLORKEY_ALPHA = &H3
Dim strData$, v
Private Sub Form_Load()
strData = "一段美轮美奂的爱情深刻的爱情" & vbCrLf & _
"你带我去看最美的风景" & vbCrLf & _
"转动在这个摩天轮里还有你送我的玩具" & vbCrLf & _
"爱上伦敦的清晰爱也很清晰" & vbCrLf & _
"双手的温度填满在心里" & vbCrLf & _
"纵使我们终究会是分开记得彼此的心"
v = Split(strData, vbCrLf)
Dim rtn&, transcolor&
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn + WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
SetLayeredWindowAttributes Me.hwnd, &HFF0000, 0, LWA_COLORKEY
End Sub
'双击文字退出
Private Sub Label1_DblClick()
End
End Sub
Private Sub Timer1_Timer()
Static i%
Label1.Caption = v(i)
i = i + 1
If i > UBound(v) Then i = 0
End Sub
Option Explicit
'窗体透明声明
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 SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Sub Form_Load()
' Me.BorderStyle = 0
'透明实现部分,可将下面的vbBlue改成窗体上(包括所有控件)任一一个不用的颜色
Form1.BackColor = vbBlue 'vbBlue
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, vbBlue, 0, LWA_COLORKEY 'vbBule
Label1.BackStyle = 0
Label1.Visible = False
Timer2.Enabled = False
Timer2.Interval = 1000
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static intNum As Integer
intNum = intNum + 1
Label1.Visible = True
Label1.Caption = "Hello world"
Timer2.Enabled = True
If intNum > 5 Then
Unload Me
End If
End Sub
Private Sub Timer2_Timer()
Label1.Visible = False
Label1.Caption = ""
Timer2.Enabled = True
End Sub
Option Explicit
Dim istr As String
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 5000
istr = "abc|def|ghi"
Text1 = ""
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static f As Boolean, n As Byte
If Not f Then
Text1 = Split(istr, "|")(n)
n = n + 1
If n = 3 Then n = 0
Timer1.Interval = 1000
Else
Text1 = ""
Timer1.Interval = 5000
End If
f = Not f
End Sub