[fpc-pascal] Program without window but messages
Jürgen Hestermann
juergen.hestermann at gmx.de
Wed Apr 25 18:14:09 CEST 2012
Howard Page-Clark schrieb:
> 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.
I also thought about this but wanted to avoid any flickering window
coming up on program start when it's created with CreateForm and
directly hidden again afterwards.
JC Chu gave an example by omitting most of the above and only leaving:
begin
Application.Initialize;
ShowMessage('TEST');
end;
This works. Though I thought that ShowMessage is not part of the LCL
so the 1.5 MB added to the program could be avoided.
But okay, if it is from the LCL then I will use the Windows API messagebox
function instead.
Thanks everybody for the hints!
I think I know now how to get on the road.
More information about the fpc-pascal
mailing list