Question Use program without form..

ExEdzy

Active member
Joined
Nov 25, 2010
Messages
37
Programming Experience
3-5
Hey guys.

I program with VB.Net some time now..
But i dont know whow can i make a program without form..
And i dont meen, hide form (Form.Hide(),Form.Visible = false) or stuf like that..
I meen, how to make program, without form, but with elements like notifiicon, openfile dialogs and all other stuff that can be used without form..

Cos i think a managed to run program without form, with sub main or something like that, but i could use any control..

For example

Dim tray as New Notifyicon
tray.visible = trye
tray.icon = my.resou....

ExEdzy
 
You need a form. Just don't show it. Set the form's ShowInTaskbar property to False and WindowState to Minimized so it doesn't get displayed initially, then handle its Shown event and call Hide or set Visible to False.
 
yeah, i know all these functions to hide.. im just wondering, is it possible to create program without form, cos there is a lot of code just to describe form, that i actualy dont need.. i think its a bit stupid.. is there really no way to make this program without form?
 
I've never actually tried it myself but, now that I think about it, you could derive your own class from ApplicationContext and then pass an instance to Application.Run in your Main method. That object could display the NotifyIcon and respond to the Click events of your ContextMenuStrip. When the user clicked the Exit menu item, you would call ExitThread. See the MSDN documentation for the Application.Run method for an example.
 
Back
Top