窗体透明,测试OK - 洛阳翼展电脑


窗体透明,测试OK

2023-3-5 乱云飞

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
'函数第一个参数是窗体句柄
'第二个指定颜色(只有第四参数有LWA_COLORKEY才有效)
'第三个参数指定不透明度(只有第四参数有LWA_ALPHA才有效)
'见上
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20&
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY As Long = &H1
Private Sub Form_Load()
Dim lOldStyle As Long
Dim bTrans As Integer '不透明度,0-255
Dim crTrans As ColorConstants '设置透明色
bTrans = 128 '自己改
crTrans = vbRed '自己改
lOldStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
SetWindowLong Me.hWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetLayeredWindowAttributes Me.hWnd, vbRed, bTrans, LWA_COLORKEY Or LWA_ALPHA
End Sub
本文链接:http://80c.cc/ez/632.html
0

发表评论:

VirtualCamera:在录像机中虚拟一个通道显示电脑桌面、视频文件、USB摄像头~
预ICP备10086-001号 © 翼展网/80C.CC 技术支持/洛阳翼展科技
TEL / 13213610060 QQ / 345794501
Powered by emlog