<br>I just compiled tiOPF and I am going through the examples which are converted from Delphi, and I am using it to understand how Lazarus GUI projects are organized<br><br>The first one I tried was this project. The program is supposed creates a dialog which probably depends on the LCL, so in order to get it work I created a new project, added a form to it, triggered the dialog from the form, then proceeded to minimize the app via experimentation until the form was not needed.<br>
<br>Below is the original project source, and following it is the Lazarus project. I guess Delphi projects automatically include some of the units with have to be added explicitly to the Lazarus project.<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
program Demo_LoadPersistenceLayerIfDef;<br><br>// Adding a {$DEFINE LINK_???} to your project, either in the DPR<br>// or the Project | Options - Conditional Defines dialog,<br>// the specified persistence layers will be linked and loaded.<br>
//<br>// When you run this demo, a dialog will show listing<br>// the loaded persistence layers. (Note, the dialog will<br>// say the database is not connected - wich is correct.)<br><br>// Take a look at tiOPFManager about line 215 you will see how<br>
// this the defines are implemented.<br><br>{$R *.res}<br><br>uses<br> DemoDBUtils in '..\Common\DemoDBUtils.pas';<br><br>begin<br> ShowConnectedDatabases;<br>end.<br></blockquote><br>Here is the pared down Lazarus equivalent<br>
<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">program Demo_LoadPersistenceLayerIfDef_Laz;<br><br>{$mode objfpc}{$H+}<br><br>uses<br> {$IFDEF UNIX}{$IFDEF UseCThreads}<br>
cthreads,<br> {$ENDIF}{$ENDIF}<br> Interfaces, // this includes the LCL widgetset<br> Forms, //frmMain,<br> LResources,<br> { you can add units after this }<br> DemoDBUtils in '..\Common\DemoDBUtils.pas';<br>
<br>{$IFDEF WINDOWS}{$R Demo_LoadPersistenceLayerIfDef_Laz.rc}{$ENDIF}<br><br>begin<br> {$I Demo_LoadPersistenceLayerIfDef_Laz.lrs}<br> Application.Initialize;<br> //Application.CreateForm(TForm1, Form1);<br> //Application.Run;<br>
DemoDBUtils.ShowConnectedDatabases;<br>end.<br></blockquote><br>I want to know if in order to display the dialog the project could be pared down further.<br>Is there some way to get the dialog to show if the project did not use TApplication?<br>
<br>Are the .rc files and .lrs files also required?<br><br clear="all">below is the DemoDBUtils unit for more clarification<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
unit DemoDBUtils;<br><br>interface<br><br>procedure ShowConnectedDatabases;<br><br>implementation<br>uses<br> tiOPFManager<br> ,tiUtils<br> ,tiDialogs<br> ,SysUtils<br> ;<br><br>procedure ShowConnectedDatabases;<br>var<br>
i: integer;<br> LS: string;<br>begin<br> LS:= '';<br> for i:= 0 to GTIOPFManager.PersistenceLayers.Count - 1 do<br> begin<br> if LS <> '' then<br> LS:= LS + Cr;<br> if Trim(GTIOPFManager.PersistenceLayers.Items[i].DBConnectionPools.DetailsAsString) = '' then<br>
LS:= LS + 'Persistence layer: "'+ GTIOPFManager.PersistenceLayers.Items[i].PersistenceLayerName +<br> '" loaded, but not connected to a database.' + Cr<br> else<br> LS:= LS + GTIOPFManager.PersistenceLayers.Items[i].DBConnectionPools.DetailsAsString + Cr<br>
end;<br><br> if LS <> '' then<br> tiAppMessage(LS)<br> else<br> tiAppMessage('No persistence layers loaded');<br>end;<br>end.<br></blockquote><br><br>-- <br>Frank Church<br><br>=======================<br>
<a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>