玩酷之家

 找回密码
 立即注册
查看: 202|回复: 0

VB 半透明窗体代码

[复制链接]
发表于 2021-1-8 16:53:56 | 显示全部楼层 |阅读模式
改变150这个数字的大小可以改变透明度!范围为0到255之间。
  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  2. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  3. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  4. Private Const WS_EX_LAYERED = &H80000
  5. Private Const GWL_EXSTYLE = (-20)
  6. Private Const LWA_ALPHA = &H2
  7. Private Const LWA_COLORKEY = &H1
  8. Private Sub Form_Load()
  9.     Dim rtn As Long
  10.     rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
  11.     rtn = rtn Or WS_EX_LAYERED
  12.     SetWindowLong hwnd, GWL_EXSTYLE, rtn
  13.     SetLayeredWindowAttributes hwnd, 0, 150, LWA_ALPHA
  14. End Sub
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|玩酷之家 ( 鄂ICP备14012049号 )

GMT+8, 2021-4-22 11:14 , Processed in 1.092002 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表