473,505 Members | 14,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System tray help

Hi all.

I am having application in vb.net.

I am having module and one form. From module i am opening form.
On main itself i am checking whether another instance of application is
running or not. I am also providing faclity of minimizing application
to system tray.
What i want is after clicking on exe of my application, it should check
whether my app is already running or not. If yes i don;t want to create
new instance but want to bring current instance in focus(that is
maxmimzing current application which is there is system tray).

Does any one is having any idea about it.
Please help me.
Thanks in advance.

Nov 21 '05 #1
8 2381
Try this:

http://www.planet-source-code.com/vb...3585&lngWId=10

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Hi.
thanks for your reply.
But i want currently running process to be in focus.
I used process class to find out whethere there is any instance of
application running or not. And if yes i want to maximize that
application. My problem is when my application is in system tray
through another application i want that application to be maximised. I
am not getting how to set that application in foreground.
Please help me if you know anything about this.
Thanks.

Nov 21 '05 #3
Hi,
You can use FindWindow API function to find main window of previous
instance, and call ShowWindow with SW_SHOWMAXIMIZED.

<tr**************@yahoo.com> ???????/???????? ? ???????? ?????????:
news:11*********************@g49g2000cwa.googlegro ups.com...
Hi.
thanks for your reply.
But i want currently running process to be in focus.
I used process class to find out whethere there is any instance of
application running or not. And if yes i want to maximize that
application. My problem is when my application is in system tray
through another application i want that application to be maximised. I
am not getting how to set that application in foreground.
Please help me if you know anything about this.
Thanks.

Nov 21 '05 #4
Hi once again.
thanks for you help.

can you tell me how to use findwindow in vb.net application.

Thanks in advance.

Nov 21 '05 #5
<tr**************@yahoo.com> ???????/???????? ? ???????? ?????????:
news:11*********************@g49g2000cwa.googlegro ups.com...
Hi once again.
thanks for you help.

can you tell me how to use findwindow in vb.net application.

Thanks in advance.


Hi,
How to use it? Like you use it in non-vb .net applications:
~
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA"
(ByVal lpClassName As IntPtr, ByVal lpWindowName As String) As IntPtr
....
Dim myWindowHandle as IntPtr = FindWindow(New IntPtr(0), "Your main window
title goes here")
~
If you are not sure if there isn't another window with same caption you can
replace "lpClassName As IntPtr" with "lpClassName As String" and "New
IntPtr(0)" with "WindowsForms10.Window.8.app3" (VB .NET forms' window
class), so you won't activate a non-.NET application instead of yours.
Nov 21 '05 #6
I wouldn't use IntPtr myself, but convert it to Integer instead

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #7
This code will take a program minimized into the system tray and restore it
to the screen with the focus instead of opening a new window.

Bobbo
__________________________________________
Public Class Form1
Inherits System.Windows.Forms.Form

Declare Auto Function FindWindow Lib "user32.dll" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Declare Auto Function ShowWindow Lib "user32.dll" _
(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean

#Region " Windows Form Designer generated code "
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Const SW_RESTORE As Integer = 9
Dim SearchText As String = Me.Text
If UBound(System.Diagnostics.Process.GetProcessesByNa me( _
System.Diagnostics.Process.GetCurrentProcess.Proce ssName)) > 0 Then
Me.Text = Me.Text & "X"
Dim Handle As IntPtr = FindWindow(Nothing, SearchText)
ShowWindow(Handle, SW_RESTORE)
End
End If
End Sub
End Class
Nov 21 '05 #8
Hi
thanks for your reply.
But this solution is not working in my case.
Because i have main from which i am displaying main form.
And in main sub itself i want to check whether previous instance of my
application is runnign or not.
And in main i am not able to set me.text property. Because i haven;t
created object of my form at the begining.
So can u tell me without chaging text of form restoring previous
instance.

Please help me.

Nov 21 '05 #9

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

Similar topics

9
6947
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When...
5
3026
by: BJ | last post by:
I am trying to add my application to the system tray. I am not using the built in control becuase of the limitation that you can not use the balloon tool tip feature. I have done this succesfully...
4
5635
by: Tom | last post by:
Hello, System tray icon informs users that the apps is running in the background. However, there are instances that the app might crash and after that the app icon in the system tray is still...
10
3115
by: Crouchie1998 | last post by:
Hello To All You Real Programmers Out There!! There is an application called: "Tray It" Webpage: ---------- http://www.teamcti.com/trayit/trayit.htm Direct Download:
5
6107
by: scottt | last post by:
I asked a question along a similar line about a week ago and didn't get any replies. Let me try to ask the quetion again a little bit different to see if I can get some help on this problem. Is...
5
9806
by: bipi | last post by:
Dear everyone, In my application, I kill process by: private bool KillProcess(String processName) { bool result = false; Process process = Process.GetProcessesByName(processName); for (int...
2
3898
by: ericlangland | last post by:
Hi, I have a small managed code application (windows forms) that executes on startup and immidiatly minimizes to the system tray. It launches and shows the form when I double click it's small...
3
4690
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, I have created a System Tray application using C# for .NET 2.0. My PC will not shut down or make a restart if my System Tray application is working at the Tray. Only after I end the process...
3
7911
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
3
3303
by: Usman Jamil | last post by:
Hi I've a windows application that does a lengthy backup process. While the process is going on, I need to show a progress bar inside system tray or just above the system tray. Can someone...
0
7098
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...
0
7303
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
7471
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...
0
5613
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,...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.