Icon in system tray (Notify Icon)
-
Hi all! I made a simple Windows Application (MyApp.exe) that shows a simple form with the system date. That application adds an icon to the system tray (a notify icon) that has associated to it a simple context Menu (Exit). So far no problems... My problem is: If i run MyApp.exe 2,3,4 or n times it adds 2,3,4,n icons to the system tray :confused: :( How can i prevent this in order to if i had already the icon of MyApp in the system tray, and if i click on MyApp.exe the focus goes to the form of MyApp and don't add a new icon to system tray?? :confused: Thanx in advance
-
Hi all! I made a simple Windows Application (MyApp.exe) that shows a simple form with the system date. That application adds an icon to the system tray (a notify icon) that has associated to it a simple context Menu (Exit). So far no problems... My problem is: If i run MyApp.exe 2,3,4 or n times it adds 2,3,4,n icons to the system tray :confused: :( How can i prevent this in order to if i had already the icon of MyApp in the system tray, and if i click on MyApp.exe the focus goes to the form of MyApp and don't add a new icon to system tray?? :confused: Thanx in advance
You just check if your app allready is running with eg. ::FindWindow(...) (you need to P/Invoke it) Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!
-
You just check if your app allready is running with eg. ::FindWindow(...) (you need to P/Invoke it) Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!
Rather than using the FindWindow API, there is a nice .NET way to find out if your app is already running. If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then If this returns true then there is another instance of the process running. What I haven't had time to work out yet is how to activate that existing instance. So if anyone knows off the top of their head how to do that, please comment. I've done plenty of this stuff with API calls in VB6 but I'd prefer to use native .NET as much as possible now. cya, Kermitt