[Lazarus] Fwd: Help clarify use of TApplication with tiOPF example.
Frank Church
vfclists at gmail.com
Sun Mar 13 00:22:14 CET 2011
---------- Forwarded message ----------
From: Frank Church <vfclists at gmail.com>
Date: 12 March 2011 22:31
Subject: Re: [Lazarus] Help clarify use of TApplication with tiOPF example.
To: Sven Barth <pascaldragon at googlemail.com>
On 12 March 2011 19:55, Sven Barth <pascaldragon at googlemail.com> wrote:
> On 12.03.2011 16:01, Frank Church wrote:
>
>> Here is the pared down Lazarus equivalent
>>
>> program Demo_LoadPersistenceLayerIfDef_Laz;
>>
>> {$mode objfpc}{$H+}
>>
>> uses
>> {$IFDEF UNIX}{$IFDEF UseCThreads}
>> cthreads,
>> {$ENDIF}{$ENDIF}
>> Interfaces, // this includes the LCL widgetset
>> Forms, //frmMain,
>>
>
> This does not include frmMain, but the common form ancestor TForm and also
> the global Application variable and its TApplication type.
>
> LResources,
>>
>
> This is needed for the inclusion of LRS files. This is not needed if RES
> files are used (don't know whether your version of Lazarus supports that
> already).
>
>
> { you can add units after this }
>> DemoDBUtils in '..\Common\DemoDBUtils.pas';
>>
>> {$IFDEF WINDOWS}{$R Demo_LoadPersistenceLayerIfDef_Laz.rc}{$ENDIF}
>>
>> begin
>> {$I Demo_LoadPersistenceLayerIfDef_Laz.lrs}
>> Application.Initialize;
>> //Application.CreateForm(TForm1, Form1);
>> //Application.Run;
>> DemoDBUtils.ShowConnectedDatabases;
>> end.
>>
>>
>> I want to know if in order to display the dialog the project could be
>> pared down further.
>> Is there some way to get the dialog to show if the project did not use
>> TApplication?
>>
>>
> You need to initialize and maybe also run the Application so that the main
> loop is executed and thus events are passed to the dialog.
> Note: when you put DemoDBUtils.ShowConnectedDatabases below Application.Run
> the call won't be executed until the application is terminated, because the
> main event processing loop is running in there.
>
>
> Are the .rc files and .lrs files also required?
>>
>>
> If you don't need an application icon, version info or a manifest (on
> Windows XP and newer) then you don't need these resources.
>
> The following is the main project source if you create a new application in
> Lazarus 0.9.31 (please note, that Lazarus does not use LRS resources by
> default anymore).
>
> ==== source begin ====
>
> program Project1;
>
>
> {$mode objfpc}{$H+}
>
> uses
> {$IFDEF UNIX}{$IFDEF UseCThreads}
> cthreads,
> {$ENDIF}{$ENDIF}
> Interfaces, // this includes the LCL widgetset
> Forms, Unit1
> { you can add units after this };
>
> {$R *.res}
>
> begin
> RequireDerivedFormResource := True;
>
> Application.Initialize;
> Application.CreateForm(TForm1, Form1);
> Application.Run;
> end.
>
> ==== source end ====
>
> I personally would suggest you to put a startup dialog into the
> applications OnShow or OnActivate event, because this is guarantied to be
> cross platform, while showing a dialog without the main loop might only work
> on Windows.
>
> Regards,
> Sven
>
I am using 0.9.28,3 with FPC 2,4,0 on Window.
I further reduced it to this
program Demo_LoadPersistenceLayerIfDef_Laz;
>
> {$mode objfpc}{$H+}
>
> uses
> {$IFDEF UNIX}{$IFDEF UseCThreads}
> cthreads,
> {$ENDIF}{$ENDIF}
> Interfaces, // this includes the LCL widgetset
> Forms, //frmMain,
> //LResources,
>
> DemoDBUtils in '..\Common\DemoDBUtils.pas';
>
> {$IFDEF WINDOWS}{$R Demo_LoadPersistenceLayerIfDef_Laz.rc}{$ENDIF}
>
> begin
> //{$I Demo_LoadPersistenceLayerIfDef_Laz.lrs}
> Application.Initialize;
> //Application.CreateForm(TForm1, Form1);
> //Application.Run;
> ShowConnectedDatabases;
> end.
>
Thanks for your response.
And it looks like Application requires Interfaces and Forms, and from what
you describe the ShowConnectedDatabases is probably only working at the end
of the program's execution. Is it possible that a GUI app will work without
TApplication on Windows, or at the least one that requires only the dialog?
--
Frank Church
=======================
http://devblog.brahmancreations.com
--
Frank Church
=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110312/843b44fb/attachment-0003.html>
More information about the Lazarus
mailing list