Ruttensoft
asked on
Start Windows Form-App hidden, only Notifyicon
Hello
How can I start a windows form-application hidden, so that only a notifyicon is visible?
The form should be started...
Thanks
How can I start a windows form-application hidden, so that only a notifyicon is visible?
The form should be started...
Thanks
ASKER
Hi Idle_Mind
I think that this is for only Tray-Icon, without any form. But I'm searching a way to load a Form, but not showing it. So when I click on it, it should set the form.visible to true and bring it it front...
I can do that all, but not load the form without showing it, cause after form_load it is showing itself always...
I think that this is for only Tray-Icon, without any form. But I'm searching a way to load a Form, but not showing it. So when I click on it, it should set the form.visible to true and bring it it front...
I can do that all, but not load the form without showing it, cause after form_load it is showing itself always...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah Thanks, I did exactly that, but I took 100 instead of 1... :-)
Yeah...that's inconsistent eh?
Design-Time = 0 --> 100
Run-Time = 0 --> 1
Design-Time = 0 --> 100
Run-Time = 0 --> 1
Click on Project --> "Add Existing Item..." and then change the "File name:" to "*.Ico" so you can select an Icon for your Tray Icon. Once an Icon has been added to your project, select and then in the Properties for it, change the "Build Action" to "Embedded Resource".
You need to change "face04.ico" to the name of the icon you added to your project.
Obviously all this app does is have an "Exit" option. You can either add more menus or trap the left click event on the NotifyIcon to show a form...
Module Module1
Public Sub Main()
Application.Run(New MyAppContext)
End Sub
Private Class MyAppContext
Inherits ApplicationContext
Private ni As New NotifyIcon
Private cm As New ContextMenu
Private mi As New MenuItem("Exit")
Public Sub New()
cm.MenuItems.Add(mi)
ni.Icon = New Icon(Me.GetType, "face04.ico")
ni.ContextMenu = cm
ni.Visible = True
AddHandler mi.Click, AddressOf Me.mi_Click
End Sub
Private Sub mi_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ni.Visible = False
Application.ExitThread()
End Sub
End Class
End Module