Is there anyway to create an application that (when created) doesn't have a form For example, I would like to create an application that has an icon in the notification bar and have it so that when I double click it a settings form is created. I would prefer not to have the form exist all along and just have it invisible because to my understanding that uses more memory then creating it on demand and the goal of this application is to make it as unobtrusive as possible.
Thanks in Advance,
Nick Dancer.

Formless Application?
Fredvanherz
Sorry I haven't replied sooner. I've been busy and we had a public holiday over here in Australia so yeah. I'm quite new to programming especially in VB and i thought all code was in a class. Anyways I figured it out and i've just got a module running and i'm running the code directly from inside that(not referring to a class). So thankyou(and everyone else) for helping me figure that out and teaching me something.
Regards,
Nick Dancer.
aymenos07
I hadn't looked at the vsm link, to be honest - just the first one (the service controller). I hadn't thought of doing it like that, but they acheive the same thing: having an object in an 'infinate loop' to keep the application running. The application object has some nice functionality associated with it, though (for example, iterating through all the open forms, or adding windows message filters).
I think either are fine, and should do what the OP (Nick) wanted by having a form in the application then creating the form when a context menu item is clicked.
Bottom line, is that I'd do exactly the sort of thing the service controller example showed. Here's a snippet from the main module in that example, which I just downloaded (Not my code - I noticed it had ye olde MsgBox in there):
Private mobNotifyIcon As NotifyIconPrivate WithEvents mobContextMenu As ContextMenu
Private WithEvents mobTimer As Timers.Timer
Private mobServiceController As System.ServiceProcess.ServiceController
Public Sub Main()
Try
'//SET UP CONECTION TO SERVICE.
mobServiceController = New System.ServiceProcess.ServiceController("IISAdmin")
'//KEEP NOTIFY ICON HIDDEN UNTIL ICON AND MENU IS SET.
mobNotifyIcon = New NotifyIcon()
mobNotifyIcon.Visible = False
mobContextMenu = New ContextMenu()
CreateMenu()
mobNotifyIcon.ContextMenu = mobContextMenu
SetUpTimer()
mobNotifyIcon.Visible = True
Application.Run()
Catch obEx As Exception
MsgBox(obEx.Message.ToString, MsgBoxStyle.Critical)
End Try
End Sub
Frank Cassata
Sayan Ghosh
Stephen,
I was just trying to figure out where you were going with your code. It was a bit different than the implementation in the VSM article and I wasn't sure how you planned on getting to the user interface settings functionality (having never attempted this approach myself).
In any event, I'm still not certain as to why the op didn't find the VSM article suitable, other than the fact that he had a desire to drive this app from a class module.
Mark Conway
Not necessarily true.
Start with the sub main, and add application.run():
Module
Module1Sub main()
Application.Run()
End Sub
End Module
Add your class instantiation before application.Run(). The nice thing about this is that your application can contain a form, and can be created if necessary, but won't be loaded by default.
Note that you will need to uncheck 'Enable Application Framework' in your Project Application settings.
LuvWhiteSand
Wasn't that the whole objective Now you have a message loop, without a form, you can create all the fun stuff like timers, System tray icons, file watchers, etc, etc.
(edited to add:) In fact, Paul, you provided a link to an application which did exactly that
.
lnielsen
auser095
Chad Magendanz
Sarev0k
I don't believe this is possible. You can launch a standard Windows app via a Windows Form or a Sub Main. A Windows Form will allow your app to remain loaded since it handles the message loop. If you use Sub Main, the application terminates once the Sub has completed executing, unless of course you spawn a new message loop (using a hidden Form) from the existing thread, as in the example provided by Lydon.
J-P Lefebvre
http://msdn.microsoft.com/coding4fun/inthebox/trickedoutapp/default.aspx
I think that's exactly what you want to do (although it does have a form).
Lydon
Active_Matrix
I am a little confused as to why no one has mentioned a simple console application
Kalpana
I'm not sure what this application will be doing but what you're describing sounds like a Windows Service. See if the following helps:
http://www.devcity.net/Articles/74/1/servicecontroller.aspx
Another method uses a standard Windows application:
http://www.ftponline.com/vsm/2003_09/online/hottips/lobel/
http://www.devarticles.com/c/a/VB.Net/Simple-VB.NET-Notify-Icon-with-Panel-Application/