473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.Diagnostics.Process.GetProcessesByNa me( _
System.Diagnostics.Process.GetCurrentProcess.Proce ssName)) > 0 Then
Const SW_RESTORE As Integer = 9
Dim SearchText As String = sender.Text
sender.Text = sender.Text & "X"
Dim Handle As IntPtr = FindWindow(Nothing, SearchText)
ShowWindow(Handle, SW_RESTORE)
sender.Text = SearchText
Return True
Else
Return False
End If
End Function
Nov 21 '05 #1
2 2621
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
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...
1
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...
1
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...
1
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...
5
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 ...
3
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...
5
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...
2
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...

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.