VB 窗口透明度设置-WindowsAPI-SetLayeredWindowAttributes
2016-12-07 12:41
1221 查看
VB 窗口透明度设置-WindowsAPI-SetLayeredWindowAttributes
1效果图
2VB代码
模块代码Option Explicit 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 ' bAlpha 0~255 0为完全透明,255为不透明 ' 其中,dwFlags参数可取以下值: ' LWA_ALPHA时:crKey参数无效,bAlpha参数有效; ' LWA_COLORKEY:窗体中的所有颜色为crKey的地方将变为透明,bAlpha参数无效。其常量值为1。 ' LWA_ALPHA | LWA_COLORKEY:crKey的地方将变为全透明,而其它地方根据bAlpha参数确定透明度。
窗体代码
Option Explicit 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, 100, LWA_ALPHA End Sub
参考资料:
http://useway.blog.51cto.com/736087/294579/
相关文章推荐
- 设置窗口的透明度SetLayeredWindowAttributes
- 使用SetLayeredWindowAttributes函数设置窗口透明色与透明度
- WinAPI: SetLayeredWindowAttributes - 设置窗口的透明
- 设置windows窗口半透明(使用SetLayeredWindowAttributes API函数)
- mfc的窗口透明度调整(SetLayeredWindowAttributes函数)
- 工作问题积累(八)SetLayeredWindowAttributes(设置透明窗体)
- 透明化窗口SetLayeredWindowAttributes
- 渐进式透明的设置(SetLayeredWindowAttributes的用法)
- 透明化窗口SetLayeredWindowAttributes
- 用SetLayeredWindowAttributes实现窗口透明
- (转)xp下实现窗体透明特效/异形窗口SetLayeredWindowAttributes函数
- 透明化窗口SetLayeredWindowAttributes
- 透明化窗口SetLayeredWindowAttributes
- 异性窗口 (解决SetLayeredWindowAttributes函数未定义的问题)
- 用SetLayeredWindowAttributes实现窗口透明
- DUI-分层窗口两种模式(SetLayeredWindowAttributes和UpdateLayeredWindow两种方法各有利弊)
- 透明窗口(窗口上面文字图片等内容不透明)的实现(使用SetLayeredWindowAttributes API函数)
- SetLayeredWindowAttributes 创建不规则窗口(此处为椭圆)
- 使用SetLayeredWindowAttributes API 实现透明窗口
- 透明化窗口SetLayeredWindowAttributes