[yoy - Why-O-Why]yoy - “Why-O-Why”

» frame | home browse filter search | refresh | log on

  printed donderdag 2 oktober 2014 10:23:27 from www.yoy.be

how-to
Comment...
Add another
Add child
Edit
Move
Delete
Add token
Add reference

Application without forms.

One type of 'application without forms', is using the {$APPTYPE CONSOLE} setting to replace the default {$APPTYPE GUI}. When using Write and WriteLn the output is sent to a command prompt box, either the one the application was started in, or a new one if the application is started from the graphical environment ( GUI).

If no commant prompt window is needed, and all you need is your exe running, you really end up with an application without forms. If you open the project source (the .dpr file) from the menu: Project > View Source, or with Ctrl+F12, you will see these lines:

Application.Initialize;
Application.Run;

Application.Initialize calls initialization some units require to be done right before the application starts, e.g. when using COM objects. Application.Run loops until the application is terminated, and processes incoming windows messages. If you add forms or datamodules, Application.CreateForm calls are added inbetween these two.

Sometimes, when using an application without forms, you get a button on the taskbar anyway. This is done every time Application.Handle is used, e.g. when using Application.MessageBox. If you don't want this, you might consider not using Application (if you don't include the Forms unit in the project the final exe-file could be much smaller!) but that might create a number of other problems. Another solution is this code, executed in the start-up code.

ShowWindow(Application.Handle,SW_HIDE);

By using the Handle property, the task-bar button is created, and by using the Windows function ShowWindow you can hide this button without changing the internal states of the Application object.

This task-bar button actually has a seperate right-click menu only with options Restore, Minimize and Close, that tie in to the Application object, which is different to the default right-click menu (SystemMenu) that has Move and Resize also. To have a taskbar-button for each window, see the CreateParams trick.

location: Application Development > Programming Languages > Object Pascal > Delphi > GUI
created: 8/06/2005 19:36:18 « modified: 8/06/2005 22:11:37 (diff) weight: 0

children, tokens, references comments (4)

delphi up down edit   del   created: 6/10/2005 14:26:10 « modified: 6/10/2005 14:26:10 weight: 0

see also -- GUI edit   del   created: 8/06/2005 19:51:28 « modified: 8/06/2005 19:51:28 weight: 0
see also -- Taskbar-button per form in an application edit   del   created: 8/06/2005 20:43:03 « modified: 8/06/2005 20:43:11 weight: 0
CreateParams