Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Tray Icon

Tray Icon

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitin_ion
    wrote on last edited by
    #1

    When i minimize my application then i want it to hide as i have a tray icon and then i can open it from there But i am not able to catch form's Minimize button event How can i minimize the form(hide)

    S K 2 Replies Last reply
    0
    • N nitin_ion

      When i minimize my application then i want it to hide as i have a tray icon and then i can open it from there But i am not able to catch form's Minimize button event How can i minimize the form(hide)

      S Offline
      S Offline
      Sonia Gupta
      wrote on last edited by
      #2

      Public Class MinimizeInTray Public TrayMenu As New ContextMenu Public Restorewindowstate As FormWindowState = FormWindowState.Normal Public trayicon As New NotifyIcon Public mainform As New Form Public visible As Boolean = False Sub New(ByVal form As Form, Optional ByVal icontext As String = "", Optional ByVal icon As Icon = Nothing) TrayMenu.MenuItems.Clear() mainform = form TrayMenu.MenuItems.Add("Restore", AddressOf restore) TrayMenu.MenuItems.Add("Close", AddressOf close) AddHandler trayicon.DoubleClick, AddressOf restore With trayicon .Visible = False If IsNothing(icon) Then .Icon = mainform.Icon Else .Icon = icon End If .Text = icontext .ContextMenu = TrayMenu End With End Sub Private Sub restore(ByVal sender As System.Object, ByVal e As System.EventArgs) mainform.ShowInTaskbar = True visible = True trayicon.Visible = False mainform.WindowState = Restorewindowstate End Sub Private Sub close(ByVal sender As System.Object, ByVal e As System.EventArgs) trayicon.Visible = False mainform.Close() End Sub End Class

      N 1 Reply Last reply
      0
      • S Sonia Gupta

        Public Class MinimizeInTray Public TrayMenu As New ContextMenu Public Restorewindowstate As FormWindowState = FormWindowState.Normal Public trayicon As New NotifyIcon Public mainform As New Form Public visible As Boolean = False Sub New(ByVal form As Form, Optional ByVal icontext As String = "", Optional ByVal icon As Icon = Nothing) TrayMenu.MenuItems.Clear() mainform = form TrayMenu.MenuItems.Add("Restore", AddressOf restore) TrayMenu.MenuItems.Add("Close", AddressOf close) AddHandler trayicon.DoubleClick, AddressOf restore With trayicon .Visible = False If IsNothing(icon) Then .Icon = mainform.Icon Else .Icon = icon End If .Text = icontext .ContextMenu = TrayMenu End With End Sub Private Sub restore(ByVal sender As System.Object, ByVal e As System.EventArgs) mainform.ShowInTaskbar = True visible = True trayicon.Visible = False mainform.WindowState = Restorewindowstate End Sub Private Sub close(ByVal sender As System.Object, ByVal e As System.EventArgs) trayicon.Visible = False mainform.Close() End Sub End Class

        N Offline
        N Offline
        nitin_ion
        wrote on last edited by
        #3

        Thanks for the code but what i want is something like outlook. if i minimize my form then it should not be visible. Not only minimize from tray icon but also from minimize button of the form to.

        S P 2 Replies Last reply
        0
        • N nitin_ion

          Thanks for the code but what i want is something like outlook. if i minimize my form then it should not be visible. Not only minimize from tray icon but also from minimize button of the form to.

          S Offline
          S Offline
          Sonia Gupta
          wrote on last edited by
          #4

          I think same code should work . just add a button to the form which indiacates the minimize sign. and put the code on that i same send.

          1 Reply Last reply
          0
          • N nitin_ion

            When i minimize my application then i want it to hide as i have a tray icon and then i can open it from there But i am not able to catch form's Minimize button event How can i minimize the form(hide)

            K Offline
            K Offline
            kubben
            wrote on last edited by
            #5

            Here is an article I wrote on this subject including balloon tips. http://www.codeproject.com/dotnet/notifyiconcontrol20.asp[^] Hope that helps. Ben

            S 1 Reply Last reply
            0
            • N nitin_ion

              Thanks for the code but what i want is something like outlook. if i minimize my form then it should not be visible. Not only minimize from tray icon but also from minimize button of the form to.

              P Offline
              P Offline
              P P Vilsad
              wrote on last edited by
              #6

              write your code on form_resize event check for form.windowstate = FormWindowState.Minimized and write your code to hide your form and show systemtray icon

              Vilsad P P MCTS (Windows Applications) .Net 2.0

              1 Reply Last reply
              0
              • K kubben

                Here is an article I wrote on this subject including balloon tips. http://www.codeproject.com/dotnet/notifyiconcontrol20.asp[^] Hope that helps. Ben

                S Offline
                S Offline
                Sonia Gupta
                wrote on last edited by
                #7

                Thank You Sir, It is very nice and useful Article.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups