Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram both as Console and GUI
    primarykey
    data
    text
    <p>Is it possible to (and if so, how do I) make a single program work both as a console application and a GUI version using Delphi 2007?</p> <p>What I am after is that if the program is run with the appropriate command-line options, it should function as a console program, printing output to the console using WRITELN, but if no command line arguments are given it should run as a normal Delphi GUI application?</p> <p>The catch is that when running as a console application, the command line interpreter waits for the application to terminate before allowing you to enter a new command, whereas a GUI application started from the command line immediately returns you to the command line and the GUI application is started in a detached process. I want this behaviour retained.</p> <p>I don't mind something like this:</p> <blockquote> <p>IF GUI THEN StartApplicationAsGUI(ParamStr(0))</p> </blockquote> <p>ie. I don't mind that I'll have to restart the application using some form of EXECUTE call to start it in GUI mode if needed, as long as the command line interface returns to the command line input when the GUI version is started.</p> <p>I'd prefer a solution/suggestion that is along the lines of:</p> <blockquote> <p>&lt;Parse Comnand Line&gt;<br> IF ConsoleMode THEN<br> &nbsp;&nbsp;&nbsp;RunConsole(Parameters)<br> ELSE BEGIN<br> &nbsp;&nbsp;&nbsp;Application.Initialize;<br> &nbsp;&nbsp;&nbsp;Application.CreateForm(...)<br> &nbsp;&nbsp;&nbsp;Application.Run;<br> END</p> </blockquote> <p>(or vice-versa, ie. doing things a special way if GUI mode)</p> <p>so that I can still use Delphi's IDE and VCL when making the GUI interface...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload