Friday, December 27, 2019
NO GUI Delphi Applications
ââ¬â¹Console applications are pure 32-bit Windows programs that run without a graphical interface. When a console application is started, Windows creates a text-mode console window through which the user can interact with the application. These applications typically dont require much user input. All the information a console application needs can be provided throughà command line parameters. For students, console applications will simplify learning Pascal and Delphi - after all, all the Pascal introductory examples are just console applications. New:à Console Application Heres how to quickly build console applications that run without a graphical interface. If you have a Delphi version newer than 4, than all you have to do is to use the Console Application Wizard. Delphi 5 introduced the console application wizard. You can reach it by pointing to File|New, this opens up a New Items dialog - in the New page select the Console Application. Note that in Delphi 6 the icon that represents a console application looks different. Double click the icon and the wizard will set up a Delphi project ready to be compiled as a console application. While you could create console mode applications in all 32-bit versions of Delphi, its not an obvious process. Lets see what you need to do in Delphi versions 4 to create an empty console project. When you start Delphi, a new project with one empty form is created by default. You have to remove this form (a GUI element) and tell Delphi that you want a console mode app. This is what you should do: Select File New Application.Select Project Remove From Project.Select Unit1 (Form1) and OK. Delphi will remove the selected unit from the uses clause of the current project.Select Project View Source.Edit your project source file:â⬠¢ Delete all the code inside begin and end.â⬠¢ After the uses keyword, replace the Forms unit with SysUtils.â⬠¢ Place {$APPTYPE CONSOLE} right under the program statement. You are now left with a very small program which looks much like a Turbo Pascal program which, if you compile it will produce a very small EXE. Note that a Delphi console program is not a DOS program because it is able to call Windows API functions and also use its ownà resources. No matter how you have created a skeleton for a console application your editor should look like: programà Project1;{$APPTYPE CONSOLE}usesà SysUtils; begin// Insert user code hereend. This is nothing more than a standardà Delphi project file, the one with theà .dpr extension. Theà programà keyword identifies this unit as a programs main source unit. When we run a project file from the IDE, Delphi uses the name of the Project file for the name of the EXE file that it creates - Delphi gives the project a default name until you save the project with a more meaningful name.Theà $APPTYPEà directive controls whether to generate a Win32 console or graphical UI application. The {$APPTYPE CONSOLE} directive (equivalent to the /CC command-line option), tells the compiler to generate a console application.Theà usesà keyword, as usual, lists all the units this unit uses (units that are part of a project). As you can see, theà SysUtilsà unit is included by default. Another unit is included too, theà Systemà unit, though this is hidden from us.In between theà beginà ...à endà pair you add your code.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.