473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Routine to restore program from system tray

Following the advice of several members, especially Dragon, I have gotten
this routine to work. If you double click on your program's icon to load
it, and it is already running minimized into the sysem tray, it will just
reopen the running instance, not create another instance. Put this Function
into a Module in a DLL and call it like

If NoLoad(Me) then END

in your Form1.Load routine. This function returns TRUE if an instance is
already running, and False if this is the first instance to be loaded.

Bobbo
_______________ _______________ _________

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

Public Function NoLoad(ByRef sender As System.Object) As Boolean
If UBound(System.D iagnostics.Proc ess.GetProcesse sByName( _
System.Diagnost ics.Process.Get CurrentProcess. ProcessName)) > 0 Then
Const SW_RESTORE As Integer = 9
Dim SearchText As String = sender.Text
sender.Text = sender.Text & "X"
Dim Handle As IntPtr = FindWindow(Noth ing, SearchText)
ShowWindow(Hand le, SW_RESTORE)
sender.Text = SearchText
Return True
Else
Return False
End If
End Function
Nov 21 '05 #1
2 2632
You see the information in this routine?

I gave you a link to a Previous Existance function, which you said was no
good, yet this uses the same thing & you say it works. That doesn't make any
sense.

Here's that link again:

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

Next, you don't need to use ShowWindow because there is AppActivate or
Me.Show etc.

You are making an easy task harder. I have many applications running on
startup (no form) & display a form it it doesn't exist & I don't ever use
ShowWindow or any other API to display it.

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
That wasn't me. I was following the thread, but had not participated in it
until I got this routine to work. Sorry for any confusion that I caused by
participating.

Bobbo
Nov 21 '05 #3

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

Similar topics

5
7356
by: Phil Galey | last post by:
VB.NET 2002 on Windows 2000 SP 3 When I start my program, the NotifyIcon appears in the tray, as it should. However, when I close the program, the NotifyIcon remains until I hover over it with my mouse. If I don't hover over it to make it disappear and then open the program again, another one is added, resulting in a multiplicity of the icon in the tray. I've even tried setting its Visible property to false, followed by a call to the...
1
4288
by: siliconpiNOSPAM | last post by:
Hi, I have a C# test program (setup as a console application) that runs a bunch of other programs like IE / etc. I run this program from a command window, the other windows cover the command window and I cannot see the log being generated. In the program execution, there are lots of delays necessary and many times when the program fails to function properly and has exited, I cannot tell whether it is in a delay loop or has exited (as...
1
1058
by: Kevin White | last post by:
Hi all, I have a program that has this basic flow: 1- Splash screen opens and creates a system tray icon (the splash screen is the main form that is started on program execution, and stays hidden to be the form that the tray icon "belongs to") 2- From the tray icon, multiple forms are opened up for data entry 3- User may or may not exit the program from the system tray icon If Windows shuts down, how does my program receive...
1
5237
by: Ranjan as usual | last post by:
Dear folks, I just completed an autoresponder program. My program should be constantly running to monitor the folder of exchange server, but I just don't want to minimize it in my test box. Is there a way to make it like a icon on the system tray, next to the system clock? Any pointers would be appreciated. cheers, Ranjan
5
2629
by: Casper | last post by:
I'm trying to get my program to run in the system tray. I've looked at dozend of tutorials on the web and on newsgroups but I just dont get it! Has anyone got any links or example code that could use? I'm using Microsoft Visual Basic 2005 Express Edition. Thanks in advance.
3
1765
by: shivaranjani.s.adimulam | last post by:
Hi, I have a problem regarding restoring previous instance of an application minimized in systray.So that when I try to run the application it should maximize its previous instance instead of creating a new one. The part of code is like - I have one function which returns the instance of the
5
6121
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 there a way (API function) from one program to restore another application that is running in the system tray? Specifically I need to send a double mouse click to the application to get it to restore from the system tray. Thanks.
2
2861
by: John Bailo | last post by:
I closed the DB2 system tray icon in Windows XP and now I can't figure out how to restore it. It doesn't reappear on reboot! Suggestions?
2
3883
by: yolilb | last post by:
hi everybody I'm using VB6 I need to restore a program that resides in the sys tray. I menage to write a function that finds the hwnd of the program but I can't figure out how to restore the program from the sys tray can someone help pls thanks
0
8411
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
8323
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
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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...
0
8613
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
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
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.