私有共享方法中的聚焦形式

时间:2016-11-30 06:39:28

标签: vb.net winforms focus

我在我的appliacyion中有一个私有共享方法,它在' Normal'中运行外部exe。点击时对焦模式。 exe完成后,MsgBox弹出窗口显示成功完成或使用默认OK按钮失败。

当用户单击“确定”按钮时,MainForm会隐藏或最小化。我怎样才能获得mainform的焦点。

我尝试使用' Me.Activate()'但是它说我只能有效地使用。

我尝试的是大型代码但下面显示的重要部分():

Imports System
Imports System.Windows.Forms
Imports System.Diagnostics

Public Class MainForm
    Inherits System.Windows.Forms.Form
    Dim WithEvents Calculate As New Button()
    Dim myProcess As Process = Nothing
    ...
    ...

<STAThreadAttribute()> _
 Public Shared Sub Main()
    Dim myMainForm As New MainForm
    Application.Run(myMainForm)
  End Sub

Public Sub New()
    ...
End Sub

Private Shared Sub Calculate_Click(sender As Object, e As System.EventArgs) Handles Calculate.Click

    Dim p As New ProcessStartInfo
        RunArgs = "SomeFile.txt"
        p.Arguments = RunArgs
        p.FileName = "Example.exe"
    myProcess = Process.Start(p)
    myProcess.WaitForExit()

    If(myProcess.ExitCode = -99) Then
        MsgBox("Successfully completed...", MsgBoxStyle.Information, "Success")
    Else
        MsgBox("Failed...", MsgBoxStyle.Critical, "Failed")
        Exit Sub    
    End If

End Class

0 个答案:

没有答案