zoukankan      html  css  js  c++  java
  • 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群

  • 相关阅读:
    万亿养老市场如何抢占商机?云巢智慧康养物联网加速器,三招化解ISV痛点!
    13个VSCode使用技巧,开启高效的开发模式
    添零占位 —— 快速生成N个0的六种办法
    使用 dumi 打包 React 组件库并生成文档站点
    Transformer架构记录(四)
    Transformer架构记录(三)
    Transformer架构记录(二)
    Transformer架构记录(一)
    NLP预训练发展小结二(Bert之后)
    p3c 插件,是怎么检查出你那屎山的代码?
  • 原文地址:https://www.cnblogs.com/garyxiao/p/3183322.html
Copyright © 2011-2022 走看看