Put application in systray
Put application in systray
Put application in systray
Put application in systray
Put application in systray
Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray
Put application in systray Put application in systray
Put application in systray
Go Back  Xtreme Visual Basic Talk > > > Put application in systray


Reply
 
Thread Tools Display Modes
  #1  
Old 07-29-2006, 11:19 PM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Question Put application in systray


I am 100% lost. I have searched through the forum on this and I am just either not understanding or finding what I need. I have an application that I want to be able to send to the systray when the user chooses to minamize the application. I have no idea how to put an icon in the systray or how to code this. Can anyone give me some very detailed examples? I have even looked through 2 of my cookbooks for VB and no luck. I am pulling my hair out here.

Thank you
Reply With Quote
  #2  
Old 07-29-2006, 11:34 PM
Teknique's Avatar
Teknique Teknique is offline
Regular
 
Join Date: Apr 2006
Posts: 60
Default

For the icon use a notify icon control and for the right clickability of the icon, use the context menu(not menustrip) that i think needs to be added to the controls box.

And then the code should look something like this.
Code:
Me.NotifyIcon.ContextMenu = Me.ContextMenu Me.Visible = False
Reply With Quote
  #3  
Old 07-29-2006, 11:38 PM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Default

Thanks but I guess thats what I am not understanding... "Use a notify icon". I don't understand how to do that...

thank you

Quote:
Originally Posted by Teknique
For the icon use a notify icon control and for the right clickability of the icon, use the context menu(not menustrip) that i think needs to be added to the controls box.

And then the code should look something like this.
Code:
Me.NotifyIcon.ContextMenu = Me.ContextMenu Me.Visible = False
Reply With Quote
  #4  
Old 07-29-2006, 11:45 PM
Teknique's Avatar
Teknique Teknique is offline
Regular
 
Join Date: Apr 2006
Posts: 60
Default

In the toolbox on the lefthand side of the screen go to the All Windows Forms Controls and select the control labeled "NotifyIcon". Then yu need to set its properties in the right and then finally do the code.
Reply With Quote
  #5  
Old 07-29-2006, 11:49 PM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Default

Ah ok... Now I see it. Ok got that and I have an icon set. Now how would I code it so that if the user hits the minimize button it shrinks down to the systay?

Thank you!!


Quote:
Originally Posted by Teknique
In the toolbox on the lefthand side of the screen go to the All Windows Forms Controls and select the control labeled "NotifyIcon". Then yu need to set its properties in the right and then finally do the code.
Reply With Quote
  #6  
Old 07-29-2006, 11:50 PM
Jabo Jabo is offline
Centurion
 
Join Date: Feb 2006
Location: Harrison,AR
Posts: 169
Default

There might be a better way to do this but since I was planning on doing this soon I looked into it a bit

Well first off, add a Notify Icon control to your form (Under Common Controls)

Then I used the resize event of the form to check and see if the windowstate property was minimized. If it was, I simply hid the form. This dual purposes and also removes the program from the task bar as well.
Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() End If End Sub
Then I chose the mouseclick event of the notify icon to show and bring the form to the front.
Code:
Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick If Me.WindowState = FormWindowState.Minimized Then Me.Show() Me.WindowState = FormWindowState.Normal End If End Sub
Well that is the simplest way I found to do it just messing with it for 5 minutes or so. Hope it helps =)
Reply With Quote
  #7  
Old 07-29-2006, 11:55 PM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Default

Hey it works! Perfect! Thank you for the help on this guys.
Reply With Quote
  #8  
Old 07-29-2006, 11:59 PM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Default

Two more question... Is there a way to display a balloon with some information really fast from the icon down there when the program loads?

Also, is there a way to code something so that if the user clicks on the X it hides the application rather then closing it?

Thanks!
Reply With Quote
  #9  
Old 07-30-2006, 12:27 AM
Jabo Jabo is offline
Centurion
 
Join Date: Feb 2006
Location: Harrison,AR
Posts: 169
Default

Code:
Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick If Me.Visible = False Then Me.Visible = True Me.WindowState = FormWindowState.Normal End If End Sub Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Visible = False End If End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If e.CloseReason = CloseReason.UserClosing Then e.Cancel = True Me.Visible = False End If End Sub
Notice how I used me.visible instead of showing and hiding the form. Well, I found out if you want to close but minimize instead, as you do, you must have a property to compare when the user clicks the notify icon.

If you bother to look around your notify icon, you will notice balloon tip properties and methods. Try something like this
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.NotifyIcon1.BalloonTipText = "Welcome~!" Me.NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info Me.NotifyIcon1.ShowBalloonTip(5) End Sub
This literally took less than 10 minutes all together by using the help screen and searching for notify icon. Good Luck tho, hope it helps.
Reply With Quote
  #10  
Old 07-30-2006, 12:45 AM
lroberts2006's Avatar
lroberts2006 lroberts2006 is offline
Contributor
 
Join Date: Mar 2006
Posts: 452
Default

Major big thanks.
Reply With Quote
  #11  
Old 07-31-2006, 12:04 PM
kingvandal kingvandal is offline
Freshman
 
Join Date: Apr 2006
Posts: 49
Default

I had been looking for a way to program to the tray. But here is something that maybe you can help with. When it minimizes it sends to tray except that it leaves it minimized to the bottom of thr screen instead of being gone totally. See screen shot. How do I make it completely go to the tray so that I have to click the tray icon to open it back up?
Attached Images
File Type: png example.PNG (6.0 KB, 35 views)
Reply With Quote
  #12  
Old 07-31-2006, 12:14 PM
inighthawki's Avatar
inighthawki inighthawki is offline
Contributor
 
Join Date: Jun 2005
Posts: 588
Default

it looks like u have it set to not show in the taskbar, which will usually make minimized items not go to the taskbar but to more of a small titlebar like in the screenshot, though not sure why using me.hide wouldnt make that invisible... just a thought, no guaranteed ideas why it would do that
__________________
Example is good. It is up to you, however, to take advantage of that example, and learn from it.
Reply With Quote
  #13  
Old 07-31-2006, 12:18 PM
kingvandal kingvandal is offline
Freshman
 
Join Date: Apr 2006
Posts: 49
Default

well I can add this much. If I change the property of the showintaskbar to ture it shows in task bar correclty without the titlebar on the far right. But then I still have the app in the task bar which is what I am trying to do away with.
Reply With Quote
  #14  
Old 07-31-2006, 01:33 PM
wayneph's Avatar
waynephPut application in systray wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Check Post #9 above. Setting Visible to False (or using Hide) should take care of the title bar sitting around. Then when the user clicks on the Icon, make sure to set Visible back to True as the example shows.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #15  
Old 07-31-2006, 04:05 PM
kingvandal kingvandal is offline
Freshman
 
Join Date: Apr 2006
Posts: 49
Default

I was getting an error at: Me.Resize

Something about Not proper indentifier.

original:
Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

updated:
Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize

Works great!

Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Put application in systray
Put application in systray
Put application in systray Put application in systray
Put application in systray
Put application in systray
Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray Put application in systray
Put application in systray
Put application in systray
 
Put application in systray
Put application in systray
 
-->