窗口淡出淡出的问题
通过TIMER控件设置FORM.Opacity属性
程序启动时 Me.Opacity = Me.Opacity + 0.1
点退出按钮后 Me.Opacity = Me.Opacity - 0.1
为什么点退出按钮后窗口淡出时,窗口内的所有控件全部变黑闪一下,然后再开始逐渐透明啊。(启动淡入时没这个问题)
PS:点窗口右上角的错叉按钮后,想要运行的代码在哪里添加。
[解决办法]
Public Class Form1 Dim sped As Single Dim WithEvents timer1 As New Timer() Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing e.Cancel = True Timer1.Enabled = True End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sped = 0.02 Timer1.Interval = 10 Timer1.Enabled = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick Me.Opacity -= sped If Me.Opacity <= sped Then Me.Close() Me.Dispose() End If End SubEnd Class