相关的属性设置如下
TrackBar Value属性:
TickFrequency: 属性:
Maximum属性:
Label Text属性: 选择窗体的透明度:
Timer Interval属性:
进入代码编辑器输入代码
首先进行声明
Public Class Form
Inherits SystemWindowsFormsForm
Dim tps As Integer
Dim bol As Boolean
进入TrackBar_Scroll事件
Private Sub TrackBar
_Scroll(ByVal sender As Object
ByVal e As System
EventArgs) Handles TrackBar
Scroll
MeOpacity = TrackBarValue /
LabelText = 窗体透明度 & CStr(MeOpacity * ) & %
End Sub
进入Timer_Tick事件
Private Sub Timer
_Tick(ByVal sender As Object
ByVal e As System
EventArgs) Handles Timer
Tick
If bol = False Then
tps = tps +
MeOpacity = tps /
If MeOpacity >= Then
TimerEnabled = False
bol = True
End If
Else
tps = tps
MeOpacity = tps /
If MeOpacity <= Then
TimerEnabled = False
bol = False
End If
End If
End Sub
进入Form_Load事件
Private Sub Form
_Load(ByVal sender As System
Object
ByVal e As System
EventArgs) Handles MyBase
Load
TimerEnabled = True
End Sub
进入Form_Closing事件
Private Sub Form
_Closing(ByVal sender As Object
ByVal e As System
ComponentModel
CancelEventArgs) Handles MyBase
Closing
TimerEnabled = True
If MsgBox(你确实要关闭窗体吗? MsgBoxStyleOkCancel) = MsgBoxResultOk Then
eCancel = False
Else
TimerEnabled = False
MeOpacity =
tps =
bol = True
eCancel = True
End If
End Sub
创建完成后我们来运行程序测试一下测试成功程序窗体是不是变得透明了通过调节滚动条我们甚至可以使得窗体消失达到完全隐形的目的这是不是很神奇呢?
[] []