Closing Process minimizes my application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sewid

    #1

    Closing Process minimizes my application

    Hi!

    I have a very simple windows form (Visual Basic, .NET-Framework 2.0).

    This is my whole code:
    Public Class Form1
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles Button1.Click
    Dim myThread As New System.Threadin g.Thread(Addres sOf
    testThread)
    myThread.Start( )
    End Sub


    Public Sub testThread()
    Dim myProcess As New Process
    myProcess.Start Info.Arguments = "fd806001"
    myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
    myProcess.Start ()
    End Sub
    End Class


    The vncviewer.exe ist the vncviewer, provided by Ultra VNC. When I
    start the Process, everything works fine and Ultra VNC launches. When
    I now close Ultra VNC, my application is in background of all open
    windows. When I switch to the vncviewer proveded by RealVNC,
    everything works fine and after closing the Viewer, my application got
    the focus back (in foreground).

    Same is with notepad++ (minimizes my application) and Windows notepad
    (correct behaviour).

    How can that be, that when I close the process my application is
    pushed in background?

    Best regards,
    Sebastian
  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: Closing Process minimizes my application

    I don't know that there is a predictable behaviour for which window becomes
    active when you close any given application. Since your process start code
    is isolated in a thread, that thread could wait for the process to exit, and
    activate the form when that occurs.

    "sewid" wrote:
    Hi!
    >
    I have a very simple windows form (Visual Basic, .NET-Framework 2.0).
    >
    This is my whole code:
    Public Class Form1
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles Button1.Click
    Dim myThread As New System.Threadin g.Thread(Addres sOf
    testThread)
    myThread.Start( )
    End Sub
    >
    >
    Public Sub testThread()
    Dim myProcess As New Process
    myProcess.Start Info.Arguments = "fd806001"
    myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
    myProcess.Start ()
    End Sub
    End Class
    >
    >
    The vncviewer.exe ist the vncviewer, provided by Ultra VNC. When I
    start the Process, everything works fine and Ultra VNC launches. When
    I now close Ultra VNC, my application is in background of all open
    windows. When I switch to the vncviewer proveded by RealVNC,
    everything works fine and after closing the Viewer, my application got
    the focus back (in foreground).
    >
    Same is with notepad++ (minimizes my application) and Windows notepad
    (correct behaviour).
    >
    How can that be, that when I close the process my application is
    pushed in background?
    >
    Best regards,
    Sebastian
    >

    Comment

    • kimiraikkonen

      #3
      Re: Closing Process minimizes my application

      On Apr 24, 1:57 pm, sewid <sebastian.widm ...@gmail.comwr ote:
      Hi!
      >
      I have a very simple windows form (Visual Basic, .NET-Framework 2.0).
      >
      This is my whole code:
      Public Class Form1
      Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
      As System.EventArg s) Handles Button1.Click
      Dim myThread As New System.Threadin g.Thread(Addres sOf
      testThread)
      myThread.Start( )
      End Sub
      >
      Public Sub testThread()
      Dim myProcess As New Process
      myProcess.Start Info.Arguments = "fd806001"
      myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
      myProcess.Start ()
      End Sub
      End Class
      >
      The vncviewer.exe ist the vncviewer, provided by Ultra VNC. When I
      start the Process, everything works fine and Ultra VNC launches. When
      I now close Ultra VNC, my application is in background of all open
      windows. When I switch to the vncviewer proveded by RealVNC,
      everything works fine and after closing the Viewer, my application got
      the focus back (in foreground).
      >
      Same is with notepad++ (minimizes my application) and Windows notepad
      (correct behaviour).
      >
      How can that be, that when I close the process my application is
      pushed in background?
      >
      Best regards,
      Sebastian
      Hi Sebastian,
      Tried with Windows notepad and closing Notepad didn't cause form
      minimizing. However though it's hard to say more without seeing other
      code and things related to TightVNC's behaviours, i recommend making
      your form got focus again:

      If i understood correctly, with using this code you'll determine that
      your process has exited by "hasExited" boolean, then if your process
      is exited and when your form is minimized for *some" reason, you can
      make your form stay with normal window state.

      ' -------- Begin -------

      Public Class Form1
      Dim myProcess As New Process

      Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
      System.EventArg s) Handles Button1.Click
      Dim myThread As New System.Threadin g.Thread(Addres sOf testThread)
      myThread.Start( )
      End Sub

      Public Sub testThread()
      myProcess.Start Info.Arguments = "fd806001"
      myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
      myProcess.Start ()


      End Sub

      Private Sub Form1_resize(By Val sender As System.Object, ByVal e As
      System.EventArg s) Handles MyBase.Resize

      If myProcess.HasEx ited = True Then

      If Me.WindowState = FormWindowState .Minimized Then
      Me.WindowState = FormWindowState .Normal
      End If
      End If
      End Sub
      End Class

      ' ------ End -------


      Hope this helps,

      Onur Güzel

      Comment

      • sewid

        #4
        Re: Closing Process minimizes my application

        Hi!

        Thanks for your answers. I tried your solution and I think, I found
        the reason. It's not your solution that fixes the problem, but the
        FormBorderStyle . I selected "FixedToolWindo w", that leads to the
        described behaviour. When I use e.g. "FixedSingl e", everything works
        fine.

        Best regards,
        Sebastian

        On 24 Apr., 13:54, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
        On Apr 24, 1:57 pm, sewid <sebastian.widm ...@gmail.comwr ote:
        >
        >
        >
        Hi!
        >
        I have a very simple windows form (Visual Basic, .NET-Framework 2.0).
        >
        This is my whole code:
        Public Class Form1
        Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
        As System.EventArg s) Handles Button1.Click
        Dim myThread As New System.Threadin g.Thread(Addres sOf
        testThread)
        myThread.Start( )
        End Sub
        >
        Public Sub testThread()
        Dim myProcess As New Process
        myProcess.Start Info.Arguments = "fd806001"
        myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
        myProcess.Start ()
        End Sub
        End Class
        >
        The vncviewer.exe ist the vncviewer, provided by Ultra VNC. When I
        start the Process, everything works fine and Ultra VNC launches. When
        I now close Ultra VNC, my application is in background of all open
        windows. When I switch to the vncviewer proveded by RealVNC,
        everything works fine and after closing the Viewer, my application got
        the focus back (in foreground).
        >
        Same is with notepad++ (minimizes my application) and Windows notepad
        (correct behaviour).
        >
        How can that be, that when I close the process my application is
        pushed in background?
        >
        Best regards,
        Sebastian
        >
        Hi Sebastian,
        Tried with Windows notepad and closing Notepad didn't cause form
        minimizing. However though it's hard to say more without seeing other
        code and things related to TightVNC's behaviours, i recommend making
        your form got focus again:
        >
        If i understood correctly, with using this code you'll determine that
        your process has exited by "hasExited" boolean, then if your process
        is exited and when your form is minimized for *some" reason, you can
        make your form stay with normal window state.
        >
        ' -------- Begin -------
        >
        Public Class Form1
        Dim myProcess As New Process
        >
        Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
        System.EventArg s) Handles Button1.Click
        Dim myThread As New System.Threadin g.Thread(Addres sOf testThread)
        myThread.Start( )
        End Sub
        >
        Public Sub testThread()
        myProcess.Start Info.Arguments = "fd806001"
        myProcess.Start Info.FileName = "D:\Tools\vncvi ewer.exe"
        myProcess.Start ()
        >
        End Sub
        >
        Private Sub Form1_resize(By Val sender As System.Object, ByVal e As
        System.EventArg s) Handles MyBase.Resize
        >
        If myProcess.HasEx ited = True Then
        >
        If Me.WindowState = FormWindowState .Minimized Then
        Me.WindowState = FormWindowState .Normal
        End If
        End If
        End Sub
        End Class
        >
        ' ------ End -------
        >
        Hope this helps,
        >
        Onur Güzel

        Comment

        Working...