How to create transparent forms in Visual Basic
http://www.vb-faq.com/Articles/Pharis/transparentform.aspHow to make a form transparent
http://www.vb-world.net/tips/tip76.html
http://www.vb-faq.com/Articles/Pharis/transparentform.aspHow to make a form transparent
http://www.vb-world.net/tips/tip76.html
Declare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Target As String
Private S1 As Integer
Private long1 As Integer
Public Function closewin(ByVal app_hWnd As Long, ByVal param As Long) As Long
Dim buf As String * 256
Dim title As String
Dim length As Long
Dim LRtn As Long length = GetWindowText(app_hWnd, buf, Len(buf))
title = Left$(buf, length)oo = Left(title, long1)
If Left(title, long1) = Target Then
LRtn = GetWindowLong(app_hWnd, GWL_EXSTYLE)
LRtn = LRtn Or WS_EX_LAYERED
SetWindowLong app_hWnd, GWL_EXSTYLE, LRtn
SetLayeredWindowAttributes app_hWnd, 0, S1, LWA_ALPHA
End If
closewin = 1
End FunctionPublic Sub pausetask(app_name As String, S As Integer)
Target = app_name
S1 = S
long1 = Len(app_name)
EnumWindows AddressOf closewin, 0
End Sub
'::::::::::::::::::::::::::::::::::::::form1 里写
Private Sub Command1_Click()
pausetask "窗口名", 80
End Sub
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPublic Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Const LWA_ALPHA = &H2
Public Const LWA_COLORKEY = &H1Form1:
Private Sub Form_Load()
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, 0, 200, LWA_ALPHA
End Sub其中:SetLayeredWindowAttributes 的第三个参数可控制透明度
人总是要成长的,让我们大家一起在CSDN里成长为新一代的高手吧!
想吵架的人闪一边去,我们只来学习,不学习的请安静!!!
想吵架的人闪一边去,我们只来学习,不学习的请安静!!!