我有一个自定义的通知表单设置,但是我下面的代码会关闭所有打开的消息框(从另一个表单打开)。这些消息框通常是问题框。
Private Sub DoneNotification_Load(sender As Object, e As EventArgs) Handles MyBase.Load
FadeInTimer.Enabled = True
End Sub
Private Sub FadeInTimer_Tick(sender As Object, e As EventArgs) Handles FadeInTimer.Tick
Dim opacityFade As Single
For opacityFade = 0 To 0.8 Step 0.01
Me.Opacity = opacityFade
Me.Refresh()
System.Threading.Thread.Sleep(1)
Next opacityFade
FadeInTimer.Enabled = False
WaitTimer.Enabled = True
End Sub
Public Sub FadeOutTimer_Tick(sender As Object, e As EventArgs) Handles FadeOutTimer.Tick
Me.Opacity -= 0.06
If Me.Opacity = 0 Then
Me.Dispose()
End If
End Sub
Private Sub WaitTimer_Tick(sender As Object, e As EventArgs) Handles WaitTimer.Tick
WaitTimer.Enabled = False
FadeOutTimer.Enabled = True
End Sub我已经尝试过me.close:
Public Sub FadeOutTimer_Tick(sender As Object, e As EventArgs) Handles FadeOutTimer.Tick
'This will decrement the opacity.
Me.Opacity -= 0.06
'Now that the form is at zero opacity we must 'dispose' of the form.
If Me.Opacity = 0 Then
Me.Close()
End If
End Sub我也尝试了一下:
Public Shared Sub FadeOutTimer_Tick(sender As Object, e As EventArgs) Handles FadeOutTimer.Tick
'This will decrement the opacity.
DoneNotification.Opacity -= 0.06
'Now that the form is at zero opacity we must 'dispose' of the form.
If DoneNotification.Opacity = 0 Then
DoneNotification.Close()
End If
End Sub非常感谢您的任何帮助。
发布于 2021-01-07 17:23:29
通过将我的通知放在另一个线程中,解决了这个问题。
https://stackoverflow.com/questions/60391630
复制相似问题