-1

在我的 vb.net windows 应用程序中,我在MouseMoveevent 中编写了一些代码。当我的应用程序运行并且光标进入我的应用程序时,一个会messagebox弹出并在一秒钟内不可见。我无法阅读其中的内容messagebox

任何人都可以帮我摆脱这个不必要messagebox的有标题.net框架。这是我的代码

Public Class ToolDashboard
    Imports System.Configuration
    Imports System.Collections.Specialized
    Public Class CompassToolDashboard
    Dim path As NameValueCollection

        Private Sub ToolDashboard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - (Me.Width - 50), Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
            path = ConfigurationManager.GetSection("ToolPath")
        End Sub

         Private Sub ToolDashboard_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
              Me.BringToFront()
              While Me.Opacity < 1
                 Me.Opacity = Me.Opacity + 0.06
             End While
        End Sub

       Private Sub ToolDashboard_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
             While Me.Opacity > 0
                Me.Opacity = Me.Opacity - 0.001
             End While
       End Sub    
       Private Sub CloseForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseForm.Click, CloseForm.Click
            Process.GetCurrentProcess().Kill()
        End Sub

        Private Sub ShareTool_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VMDashboard.Click
            System.Diagnostics.Process.Start(path("IndexGenerator")) 
        'getting path for Indexgenerator.exe from app.config                 
        'Index generator.exe is present in a remote system      
        End Sub
 End Class
4

2 回答 2

1

MessageBox可能是由于ConfigurationManager.GetSection. 您必须使用断点来验证这一点,或者将您的 IDE 配置为自动中断异常(在 Visual Studio 2008 中:调试 > 异常...,在公共语言运行时异常旁边放置一个复选标记)。


事件处理程序中的 while 循环不会像您期望的那样执行渐变动画。您可以使用Timer. 另外,如果您将所有方式设置为 0.0 ,我相信表单将无法接收MouseEnter事件。Opacity这是一个在 0.3 和 1.0 之间渐变的示例:

Private WithEvents timer As New Timer()
Private visible As Boolean

Public Sub New()
    InitializeComponent()
    timer.Interval = 1
    Opacity = 0.3
End Sub

Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
    visible = True
    timer.Start()
    MyBase.OnMouseEnter(e)
End Sub

Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
    visible = False
    timer.Start()
    MyBase.OnMouseLeave(e)
End Sub

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles timer.Tick
    If (visible) Then
        If (Opacity < 0.94) Then
            Opacity += 0.06
        Else
            Opacity = 1.0
            timer.Stop()
        End If
    Else
        If (Opacity > 0.31) Then
            Opacity -= 0.01
        Else
            Opacity = 0.3
            timer.Stop()
        End If
    End If
End Sub
于 2013-08-01T13:37:52.750 回答
0

我不确定messagebox你在说什么,但该方法ToolDashboard_MouseMove不应该在里面有这个while循环,因为它会让你的应用程序在第一次触发时就卡住了,所以它永远不会离开,也永远不会继续应用程序。相反,您应该在您想要的特定控件上使用鼠标进入鼠标离开事件,如果您没有控件,您应该创建一个面板或类似的东西,用户不会看到,但您将能够使用事件。

于 2013-08-01T06:16:48.850 回答