Maximize an External Application which is minimized in the system tray using VB.Net
Hi Guys!
I do have a problem which involves my current project. I already had the codes to switch the program in the system tray after it was minimized and vice versa. The problem is if I run again another instance of the same program, I do want the current instance to be maximized and then disregard the new instance to be run. A good example that I can relate was the Yahoo Messenger App. In Yahoo Messenger App, if there is a current instance running and then you tried to run another, the current instance will be pulled out on the system tray and show it on its normal state. It is exactly what I wanted to do.
If anyone here knows how to do it, Please I need your help.
Thanks in advance guys!
Re: Maximize an External Application which is minimized in the system tray using VB.N
you could use 2 api functions: findwindow + showwindow
Re: Maximize an External Application which is minimized in the system tray using VB.N
VB.NET has an option to make single instance application, do the following
1- Go to the menu Project> prj_name Properties...
2- In the application tab select the option "Make single instance application"
3- In the application tab press a button labeled with "View Application Events"
4- A module named "ApplicationEvents.vb" will open, paste the following inside it
Code:
Private Sub MyApplication_StartupNextInstance(sender As Object, e As ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
Form1.Show() ' replace Form1 with the name of your main form.
End Sub
Re: Maximize an External Application which is minimized in the system tray using VB.N
sorry. didn't read the question properly
Re: Maximize an External Application which is minimized in the system tray using VB.N
Quote:
Originally Posted by
4x2y
VB.NET has an option to make single instance application, do the following
1- Go to the menu Project> prj_name Properties...
2- In the application tab select the option "
Make single instance application"
3- In the application tab press a button labeled with "View Application Events"
4- A module named "ApplicationEvents.vb" will open, paste the following inside it
Code:
Private Sub MyApplication_StartupNextInstance(sender As Object, e As ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
Form1.Show() ' replace Form1 with the name of your main form.
End Sub
Don't you want Me.Show instead of FormName.Show.
Re: Maximize an External Application which is minimized in the system tray using VB.N
Quote:
Don't you want Me.Show instead of FormName.Show.
No you cannot use Me keyword because that line is in a different module.
Edit:
The following is better
Code:
Private Sub MyApplication_StartupNextInstance(sender As Object, e As ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
My.Application.MainForm.Show()
End Sub