[fpc-pascal] Program without window but messages

Howard Page-Clark hdpc at talktalk.net
Tue Apr 24 19:37:32 CEST 2012


On 24/4/12 5:25, Jürgen Hestermann wrote:
> I wanted to write a program that has no window but may show messages to
> the user.
> I have lots of such programs written with Virtual Pascal but I am
> struggling
> to do the same with Free Pascal/Lazarus.
>
> A simple test program would look like this:
>
> --------------------------------
> program Test;
> {$mode objfpc}{$H+}
> uses Interfaces,Forms,Windows,SysUtils,Dialogs;
> {$R *.res}
>
> begin
> ShowMessage('TEST');
> end.
> --------------------------------

> Creating a console program is not an option because it will create a
> console window which I don't need.
>
> Anybody who knows why it is like that?

A GUI program requires a "main window" since that is the avenue for user 
interaction. You can hide that window (not "ignore" it) as in the 
following program, which compiles and runs. However, I can't myself see 
the use of such truncated GUI functionality. Once the main form is 
hidden, I see no way for the user ever to get back to it.

program Project1;

{$mode objfpc}{$H+}

uses
   Interfaces, Forms, Unit1, Dialogs;

{$R *.res}

begin
   Application.Initialize;
   Application.CreateForm(TForm1, Form1);
   Form1.Hide;
   ShowMessage('TEST');
   Form1.Close;
   Application.Run;
end.




More information about the fpc-pascal mailing list