• vb将窗体中的控件或某种颜色透明


    Option Explicit
    ' ******************** 窗体透明 ********************
    '***Module.bas
    '****
    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
    Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    
    Public Const WS_EX_LAYERED = &H80000
    Public Const GWL_EXSTYLE = (-20)
    Public Const LWA_ALPHA = &H2
    Public Const LWA_COLORKEY = &H1
    Public Const WS_EX_TRANSPARENT = &H20&
    
    '**************
    '***Form1.frm
    '-------------------------------------------------**
    Private Sub Form_Load()
        Dim rtn As Long
        rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
    
        '全窗体  完全透明, 通透         全消失
    '    SetWindowLong hwnd, GWL_EXSTYLE, rtn Or WS_EX_LAYERED
    
        '    '将某个色彩 完全通透           部分消失
    '        lbl.BackColor = vbBlue                                      '设置一个色彩
    '        Form1.BackColor = vbBlue
    '        SetWindowLong hwnd, GWL_EXSTYLE, rtn Or WS_EX_LAYERED
    '        SetLayeredWindowAttributes hwnd, vbBlue, 0, LWA_COLORKEY
    
        '    '通透 ,  半透明
    '        SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
    '        SetLayeredWindowAttributes Me.hwnd, 0, 128, LWA_ALPHA      ' The level of transparency (0 - 255)
    
        '不通透,    半透明
        SetWindowLong hwnd, GWL_EXSTYLE, rtn Or WS_EX_LAYERED
        SetLayeredWindowAttributes hwnd, 0, 200, LWA_ALPHA   '(句柄  ,掩码颜色[RGB]  ,  透明程度[0-255],  )
        'hwnd
        'crKey               为颜色值,// 掩码的颜色,可以用RGB(r,g,b)来指定
        'bAlpha          是透明度,取值范围是[0,255]
        'dwFlags     是透明方式,可以取两个值:
        '                =LWA_ALPHA时,crKey参数无效,bAlpha参数有效;
        '                =LWA_COLORKEY时,窗体中的所有颜色为crKey的地方将变为透明,bAlpha参数无效。
        '
    End Sub
    

    摘自QQ群

  • 相关阅读:
    【网络安全】十三步简单入侵个人电脑教程
    [深入学习Web安全](11)之XSS玩法
    W3bsafe]SQLmap过狗命令的利用+教程
    Python 爬虫修养-处理动态网页
    WEB站点服务器安全配置
    jboss final 7.1.1相关error以及解决方式
    “System.IO.FileNotFoundException”类型的未经处理的异常在 mscorlib.dll 中发生
    HDU 2196 Computer 树形DP经典题
    python3连接Mairadb数据库
    jQuery动画animate()的使用
  • 原文地址:https://www.cnblogs.com/garyxiao/p/3183322.html
Copyright © 2020-2023  润新知