相關的屬性設置如下
TrackBar Value屬性:
TickFrequency: 屬性:
Maximum屬性:
Label Text屬性: 選擇窗體的透明度:
Timer Interval屬性:
進入代碼編輯器輸入代碼
首先進行聲明
Public Class Form
Inherits System
Windows
Forms
Form
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
Me
Opacity = TrackBar
Value /
Label
Text =
窗體透明度
& CStr(Me
Opacity *
) &
%
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 +
Me
Opacity = tps /
If Me
Opacity >=
Then
Timer
Enabled = False
bol = True
End If
Else
tps = tps
Me
Opacity = tps /
If Me
Opacity <=
Then
Timer
Enabled = 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
Timer
Enabled = True
End Sub
進入Form_Closing事件
Private Sub Form
_Closing(ByVal sender As Object
ByVal e As System
ComponentModel
CancelEventArgs) Handles MyBase
Closing
Timer
Enabled = True
If MsgBox(
你確實要關閉窗體嗎?
MsgBoxStyle
OkCancel) = MsgBoxResult
Ok Then
e
Cancel = False
Else
Timer
Enabled = False
Me
Opacity =
tps =
bol = True
e
Cancel = True
End If
End Sub
創建完成後我們來運行程序測試一下測試成功程序窗體是不是變得透明了通過調節滾動條我們甚至可以使得窗體消失達到完全隱形的目的這是不是很神奇呢?
[] []
From:http://tw.wingwit.com/Article/program/net/201311/14510.html