Startup Programs


Ok i have a made a program but encounterd some problems. My Program is acutally a reminder program where it will show a msgbox the user when it is time.

1.) I want to make it a startup program and i know to do that i have to put the .exe file under C:\Documents and Settings\user\Start Menu\Programs\startup.
But if i distrubute this program with an installer, lets say with clickonce publishing which is the default. How can i make the installer put the .exe file
under the startup folder


2.)When the program startsup it should be hidden, like antivirus programs; they startup hidden with only a notify icon running. There should only be the notify icon.
So how can i do that


3.)Also i want the notify icon to have a menu. See the screenshot. I want that kind of menu in my notify icon with only exit and open , for opening the program
How can i do that

Screenshot:http://img58.imageshack.us/img58/8458/icon2br.jpg




Answer this question

Startup Programs

  • Sami Vaaraniemi

    < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    Public Class Form1

        Friend WithEvents ni As New NotifyIcon

        Friend WithEvents nimenu As New ContextMenu

        Protected Const cItem1 As String = "Item1"

        Protected Const cItem2 As String = "Item2"

        Friend WithEvents OKButton As New Button

        Protected lb1 As New Label

     

     

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Me.ShowInTaskbar = False

            Me.Visible = False

            OKButton.Text = "OK"

            Me.Controls.Add(OKButton)

            Me.Controls.Add(lb1)

            lb1.Location = New Point(100, 100)

            OKButton.Location = New Point(200, 200)

            ni.Icon = Me.Icon  ' Borrow the forms icon

            ni.Visible = True

            ni.ContextMenu = nimenu

            nimenu.MenuItems.Add(CreateMenuItem(cItem1))

            nimenu.MenuItems.Add(CreateMenuItem(cItem2))

     

        End Sub

     

        Private Function CreateMenuItem(ByVal Name As String) As MenuItem

            Dim b As New mi

            Return b.GetMenuitem(Name)

        End Function

     

        Public Sub ItemDispatch(ByVal Name As String)

            Me.Visible = True

            Select Case Name

                Case cItem1

                    Item1Processing()

                Case cItem2

                    Item2Processing()

            End Select

        End Sub

        Private Sub Item1Processing()

            lb1.Text = "You selected Item1"

        End Sub

        Private Sub Item2Processing()

            lb1.Text = "You selected Item2"

        End Sub

     

        Private Sub OKButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OKButton.Click

            Me.Hide()

            'process OK here

        End Sub

    End Class

     

    Public Class mi

        Friend WithEvents foo As New MenuItem

        Public Function GetMenuitem(ByVal Name As String) As MenuItem

            foo.Text = Name

            foo.Name = Name

            Return foo

        End Function

        Private Sub foo_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles foo.Click

            Form1.ItemDispatch(CType(sender, MenuItem).Text)

        End Sub

     

    End Class

     

     

    Enjoy... this works well....... I couldn't see your screenshot but this has a flexible menu capability.



  • Startup Programs