VB_窗体透明
来源:互联网 发布:ios源码 编辑:程序博客网 时间:2024/05/08 15:41
我们知道VB没有Delphi的直接可以改变透明度的属性,那么就需要使用API来实现了也~
- Private Const LWA_ALPHA =
- Private Const LWA_COLORKEY =
- Private Const GWL_EXSTYLE = -20
- Private Const WS_EX_LAYERED =
- ’定义一些常数,用于API函数的使用
- Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long) As Long
- Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal Hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
- Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- ’hwnd表示一个窗口的句柄,用来控制一个窗口是必备的,每一次窗口载入后的句柄是不同
- ’的!
- '定义了一个子过程,来调用上面几个API函数
- Public Sub setfrm(frm As Form, ByVal limpid As Long) ' 设置窗体透明度
- Call SetWindowLong(frm.Hwnd, GWL_EXSTYLE, GetWindowLong(frm.Hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
- Call SetLayeredWindowAttributes(frm.Hwnd, 0, limpid, LWA_ALPHA) 'limpid在0--255之间
- End Sub
- ’以上的代码可以放在窗口代码中,不过最好放在一个模块下。
- Private Sub Form_Load()
- setfrm Me, 200'设置透明度为200,透明度可以是0~255的任意整数,注意也可以表示成
- 'Call setfrm (me,200)
- End Sub
而如果要做到类似千千的淡入淡出的效果,用个时间控件就可以了
- Private Const LWA_ALPHA =
- Private Const LWA_COLORKEY =
- Private Const GWL_EXSTYLE = -20
- Private Const WS_EX_LAYERED =
- '定义一些常数,用于API函数的使用
- Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long) As Long
- Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal Hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
- Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- 'hwnd表示一个窗口的句柄,用来控制一个窗口是必备的,每一次窗口载入后的句柄是不同
- '的!
- '定义了一个子过程,来调用上面几个API函数
- Public Sub setfrm(frm As Form, ByVal limpid As Long) ' 设置窗体透明度
- Call SetWindowLong(frm.Hwnd, GWL_EXSTYLE, GetWindowLong(frm.Hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
- Call SetLayeredWindowAttributes(frm.Hwnd, 0, limpid, LWA_ALPHA) 'limpid在0--255之间
- End Sub
- '以上的代码可以放在窗口代码中,不过最好放在一个模块下。
- Private Sub Form_Load()
- Timer1.Enabled = 1’令时间控件响应事件
- Timer1.Interval = 10’定义间隔时间
- End Sub
- Private Sub Timer1_Timer()
- Static i%
- i = i + 2
- If i < 253 Then
- setfrm Me, i
- Else
- Timer1.Enabled = 0
- End If
- End Sub'一个十分简单的循环
- VB_窗体透明
- 窗体透明
- 透明窗体
- 透明窗体
- 透明窗体
- 透明窗体
- 透明窗体子窗体显示
- 分层窗体,透明窗体(转)
- vb实现透明窗体
- 如何制作透明窗体
- 透明窗体的实现
- 创建透明窗体
- 创建透明窗体
- VC 制作透明窗体
- c#透明窗体
- 实现透明窗体
- 创建透明 Windows 窗体
- 窗体透明效果
- CORBA探索(第一篇:学习CORBA应理解的一些基本概念)
- VB_KeyCodeConstants 枚举值
- 用反射写的数据绑定
- 模式窗口一些常用的处理
- csdn开博啦
- VB_窗体透明
- Who can understand this statement below?
- 零散的记录
- Linux configure 参数解释
- C运行时库详解(转载)
- 转发和重定向的区别
- RedHat Linux安装Oracle10g(图文详解 教程)
- COM组件简介
- 排序算法空间、时间复杂度