[fpc-pascal] Program without window but messages

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Apr 24 18:25:03 CEST 2012


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

When I create a new project and select to create an "Application",
copy the above into the main program (ignoring Unit1.pas) and run
the program I get an exception "Fensterklasse nicht gefunden" (in
german, although I setup Lazarus in english!) and I am put into
Win32WSControls.

When I try the same with a new "Program" and use the same test file
(just omitting Interfaces and Forms units, because Lazarus cannot find it.
Why? I did find it when creating an "Application")  I cannot even
compile it because I get:

project1.lpr(10,12) Error: Identifier not found "ShowMessage"

The wiki ( http://wiki.freepascal.org/Dialog_Examples/de#ShowMessage )
says that this function is definied in Dialogs which I included in my
uses clause. Still it cannot find it. Why is ShowMessage not available?

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?





More information about the fpc-pascal mailing list