[lazarus] Interface Initialization

Vincent Snijders VSDS at RND.VB.CBS.NL
Mon Nov 25 04:16:18 EST 2002


> -----Original Message-----
> From: Mattias Gaertner [mailto:nc-gaertnma at netcologne.de]
>
> On Sat, 23 Nov 2002 22:33:48 +0100
> "Vincent Snijders" <vslist at zonnet.nl> wrote:
> 
> > I have seen that constructor and destructor of the 
> gtk-interface objects
> > are not quite balanced. There is also a lot of clean up 
> which IMO belongs
> > to the AppTerminate method.
> 
> What code?

For example the code to clear unsent paint messages and stop running timers.

> > Wouldn't it be better to create and initialize the 
> interface object in the
> > application.Initialize and To destroy it in the 
> Application.Terminate?
> > Then moving between Create doesn't matter anymore.
> > 
> > The interfaces unit must then set a class for the interface, like:
> > 
> > type
> >   LCLWidgetInterface = class of InterfaceBase;
> > 
> > initialize
> >   LCLWidgetInterface = TGTKObject;
> > 
> > In the Application.Initialize code like this could be used:
> >   InterfaceObject := LCLWidgetClass.Create;
> 
> Application.Initialize is called at the start of the program 
> _after_ all
> initialization sections. Units like synedit need the 
> interface object in
> their initialization section. So, we must create the 
> interface object in one
> of the initialization sections of the LCL. The only choices 
> we have here is
> gtk/interfaces.pp or gtk/gtkint.pp. They are the topmost units of the
> gtk-lcl.

Is this realy true at the moment? I tried to start lazarus without setting an interfaceobject in the interfaces unit and create an interface object just before calling application.initialize and it did seem to start OK.

Let me explain the reason for this request. I am trying to create a testprogram with some tests to see whether changes I make to get the win32 interface working don't break the gtk interface on linux. It also helps me to see if things work the same. Basicly I want to do the following:

//Test program with one form
Application.Initialize; //calls InterfaceObject.Init
Application.CreateForm(TTestForm1,TestForm1);
Application.Run; //Ultimately calls InterfaceObject.AppTerminate

//Test program with two forms
Application.Initialize; //calls InterfaceObject.Init
Application.CreateForm(TTestForm2,TestForm2);
Application.CreateForm(TTestForm3,TestForm3);
Application.Run; //Ultimately calls InterfaceObject.AppTerminate

etc...

An other advantage of postponing interface object creation is that the type of interface could be selected at run-time, i.e. by a command line switch offering to use gtk or win32 interface.






More information about the Lazarus mailing list