Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SystemTray Icon and Windows Startup 2

Status
Not open for further replies.

vbSun

Programmer
Dec 9, 2002
504
US
Hello all,

I need help implementing this feature for my latest program. The program has an icon on the system tray and optionally starts when windows starts. If it's launched through the Start menu then the application appears. If it launches with Windows then an icon will just appear in the system tray. How can this be done?

My thoughts was to implement a twin exe system, where the windows startup launches the app to show the toolbar icon, and the other, the actual application..

What do you people think about it? Do i really have to employ two exes? or just one?

all help much appreciated..

Thankyou
 

I would guess that a dual exe system is really not worth it because of keeping up with the code base, but then again I do not know what your system is either.

So I would suggest that you check out the Command object and in your sub main you would test this to see what command line parameters are passed to your program. Now with that said you would have to modify the link that the user would use to start your program and your testing would be for that parameter and whether to show user interface or not.

Good Luck

 
Thanks vb5Programmer,

Lets see what the Command$ brings me... i will let you know about it..

Thanks,
Sunil
 
But Command is really an object? I thought its a variable and returns the filename, when you are double clicking from the explorer on some file to display it in the app. The bottom line is, even if i run the application in VBIDE, if the app launches at startup, if the app is an exe etc.. the Command$ is an empty string.

Any other ideas VB5Programmer? or am i missing something here?
 

Here is a simple test that you can perform to test the Command Object and how it works. Start a new standard exe project, add a module (module1) and set the properties to startup at sub main. Then add the following code to module1...
[tt]
Option Explicit

Sub Main()

If UCase(Command) = UCase("ShowForm") Then
Form1.Show
ElseIf Trim(Command) <> vbNullString Then
MsgBox Command
End If

End Sub
[/tt]

Save and compile the project (Project1) in an easy place to remember.

Now start the command prompt and navigate to where you saved and compiled your project.

Then type in project1.exe test (then click ok)

type in project1.exe showform

close the form

Start a new standard exe project and add a command button to form1 (command1). Type in the following...
[tt]
Shell &quot;your path to project1\project1.exe showform&quot;
Shell &quot;your path to project1\project1.exe test&quot;
[/tt]

Ok that should explain how the command object works. Now for creating a shortcut with command line parameters see this thread222-665773 where Adoozer gives an example or this thread222-166458 where CajunCenturion gives an example and Lightseeker gives a link (which was not working to well as of this posting).

Good Luck

 
Thanks VB5Programmer,

Now i understand what it is. Sorry it took some time. This is what i have done to solve it.

Create a registry key like this..

Software\Microsoft\Windows\CurrentVersion\Run&quot;, &quot;My Program Name&quot;, App.Path & &quot;\my prog name.exe silent&quot;

And check like this

If UCase(Command) = UCase(&quot;silent&quot;) Then
Load Form1
Form1.Visible = False
Else
Form1.Show
End If

Thanks a lot,
Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top