473,734 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jun 27 '08 #1
3 1399
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
Jun 27 '08 #2
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

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 "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
Jun 27 '08 #4

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

Similar topics

2
3181
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 console application named "etm.exe", I would like to call it in my .net (VC) application. What I want to do is when the user type some command in my .net application, I redirect this command
0
1076
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 notifyicon, and hidden when the user minimizes the form) The problem I've run into is that Process class is unable to close the application using either the CloseMainWindow() or Close() method, when the form is hidden. It seems that the form's...
10
4025
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
10
1825
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 upper right hand for instance, or Alt+4, etc.) Or is this even necessary? -- Thanks, Ricky W. Hunt freendeed
2
2269
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 the list for each time the extract has been run. I cannot seem to find anything on this, I have the application closing properly as far as I can see, but it is staying in the process table and the only way to get rid of it is to either reboot...
4
12375
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); wordprocess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; wordprocess.StartInfo.WorkingDirectory = TemplatePath.Substring(0, TemplatePath.Length - 1);
5
21935
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 add to the schedule to close it? What object can be used to reference another application? TIA -- Helen
2
2561
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 messages in the label on the form as the shutdown cleanup proceeds. I have a hidden Startup form. So in the Startup form OnClose event, I am loading the message form and then changing the label caption as the code proceeds to do the cleanup of...
2
3050
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, I tried to kill excel process but i find it difficult to figure out which is the right process to kill .It is out of question to kill all process on the server so i have to find out which is the proper one bit I can't retrieve the id of the process...
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.