473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf
testThread)
myThread.Start()
End Sub
Public Sub testThread()
Dim myProcess As New Process
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.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
Jun 27 '08 #1
3 1390
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(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf
testThread)
myThread.Start()
End Sub
Public Sub testThread()
Dim myProcess As New Process
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.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
Jun 27 '08 #2
On Apr 24, 1:57 pm, sewid <sebastian.widm...@gmail.comwrote:
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(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf
testThread)
myThread.Start()
End Sub

Public Sub testThread()
Dim myProcess As New Process
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf testThread)
myThread.Start()
End Sub

Public Sub testThread()
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.exe"
myProcess.Start()
End Sub

Private Sub Form1_resize(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

If myProcess.HasExited = 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

Jun 27 '08 #3
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 "FixedToolWindow", that leads to the
described behaviour. When I use e.g. "FixedSingle", everything works
fine.

Best regards,
Sebastian

On 24 Apr., 13:54, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Apr 24, 1:57 pm, sewid <sebastian.widm...@gmail.comwrote:
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(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf
testThread)
myThread.Start()
End Sub
Public Sub testThread()
Dim myProcess As New Process
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf testThread)
myThread.Start()
End Sub

Public Sub testThread()
myProcess.StartInfo.Arguments = "fd806001"
myProcess.StartInfo.FileName = "D:\Tools\vncviewer.exe"
myProcess.Start()

End Sub

Private Sub Form1_resize(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

If myProcess.HasExited = 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
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ivan Lam | last post by:
Hi all, Thanks for reading my post!!! I am facing a problem that I cannot redirect StandartOutput and StandardInput at the same time without closing the executive. Actually, I have a...
0
by: tim | last post by:
I have an vb application that is started/stopped using the System.Diagnostics.Process class. The application has both a form, and a notifyicon. (The form is displayed when the user clicks the...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
10
by: Ricky W. Hunt | last post by:
I have written a close routine to handle an "Exit" button to close the application properly. How do I make sure this gets executed if the user closes it another way (by pressing the "X" in the...
2
by: Atley | last post by:
I have written an application that exports data from SQL to Excel. It all works perfectly except that if you open the Task Manager after running my application, there is an instance of Excel in...
4
by: Paul | last post by:
Hi, I am trying to start a process hidden. My code: wordprocess = new System.Diagnostics.Process(); ; wordprocess.StartInfo = new System.Diagnostics.ProcessStartInfo(wcmd, args);...
5
by: Helen Trim | last post by:
I have scheduled programs that run overnight. One of them leaves a window open and this stops other users opening the program. It is a third-party application. Can I write a vb .NET program to...
2
by: rdemyan via AccessMonster.com | last post by:
I have a custom message form that I want to display when the user shuts down my app. Some clean up needs to be done during shutdown and I want to display this form and then display various...
2
by: Ronin85 | last post by:
Hi , I recently have much pain working with excel application especially closing excel . I try several method but with no success i try to urge garbage collector to dispose excel application object,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.