Results 1 to 7 of 7

Thread: [RESOLVED] I need a special type of project

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [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.

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    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.

  3. #3
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    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.

  6. #6
    Addicted Member
    Join Date
    Mar 2007
    Posts
    163

    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

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width