首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自定义通知关闭消息框

自定义通知关闭消息框
EN

Stack Overflow用户
提问于 2020-02-25 17:45:41
回答 1查看 40关注 0票数 0

我有一个自定义的通知表单设置,但是我下面的代码会关闭所有打开的消息框(从另一个表单打开)。这些消息框通常是问题框。

代码语言:javascript
运行
复制
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:

代码语言:javascript
运行
复制
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

我也尝试了一下:

代码语言:javascript
运行
复制
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

非常感谢您的任何帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-07 17:23:29

通过将我的通知放在另一个线程中,解决了这个问题。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60391630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档