[RESOLVED] I need a special type of project
Hello everyone.
I am currently working on a launcher, and it must consist of the following:
- one main routine being called, NO WINDOW may be created at any times after or before this main routine.
- one small form called by the main routine if a certain command was sent through the Command (shortcut).
At this point I use a Windows Form, but it seems a little useless to create and initialize a form if you won't even use it. Any way to make a routine run when my program starts without showing any window? But still make it possible to show that small dialog?
I did this at first but it seems a bit dangerous:
Code:
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Main()
End Sub
Code:
Sub Main()
'Code to run here
End Sub
It starts another program (process) which has a GUI, so I do not want to display a console window. It would look ugly.
Re: I need a special type of project
From a Windows perspective, all you need to do is start up a message pump. This is getting in to low level details, so be sure you actually want to do this and really can't get away with showing a window before you start down this road.
Re: I need a special type of project
Although having said that, this wouldn't be the first time that VB has surprised me with the flexibility of its Application Framework option, so someone will probably come along and show you the magic checkbox to tick/untick. I'd have you writing custom ApplicationContexts.
Re: I need a special type of project
Do you want your app to stay resident after you start it or do you want it to do it's thing and exit?
Regardless, you may want to follow the CodeBank link in my signature and check out my thread on creating a Formless Tray Application. It shows how to create a WinForms app with no main form. You can adapt that as required, e.g. with or without a tray icon, display a form on startup or not based on a commandline argument, etc.
Re: I need a special type of project
At this point all it will do is make java launch a .jar file (with arguments) based on what the launcher has for arguments. Plus clicking a button in the resulting window (using API's) which is working.
After the script is fully launched it will close.
I already have a way of doing this, but it gives errors in the designer and still requires the program to make an (useless) form. (form gets created regardless of what I change, so I need to close it on formload).
All I want is a simple program, with a main subroutine like a module, but then without an attached console. The console is the issue, since hiding the console using API's still displays the console for a second.
Re: I need a special type of project
Have a look at creating a background formless application then.
Create your module, add a main method to it like you have done anyway and then in the project properties in the "Startup object" you can use your module rather than a form...
All these said I do suggest that you have a look at what jmcilhinney indicated, as it is pretty much exactly what you want to do
Re: I need a special type of project
Oow so that is what he meant. Couldn't find a link so I thought it was about using a notifyicon or something.
Had to make a console application and, in the project properties, change the Startup Object to "Sub Main" and the Application Type to "Windows Forms Application".
I got it to work perfectly, thank you all. :bigyello: