Advanced Xailer Techniques, The application starting code (I)
[Original post by José F. Giménez]
When we are working with Xailer, the most common thing we do is to crete a project, then create a main form. This creates two source code modules, one with the same project name and other with a different name, given by us, when saving the file.
/*
* Proyecto: Ejemplo1
* Fichero: Ejemplo1.prg
* Descripción: Módulo de entrada a la aplicación
* Autor:
* Fecha: 13/10/2005
*/
#include "Xailer.ch"
//-------------------------------------------------------
Procedure Main()
Application:cTitle :="Ejemplo1"
Application:oIcon :="Icono1"
TForm1():New( Application ):Show()
Application:Run()
Return
//-------------------------------------------------------
As you can see, this function (procedure) just assign some properties to the Application object, the main form is created and shown, and finally, the call toApplication:Run(), starts the program's message loop.
This code is created by the IDE, adding, removing or changing lines when ever we make a change in the project's configuration. But, some times, you may not be interested on create and show a form, may be you could be interested on write the starting code by yourself. If you try and change the code by hand, the IDE will change it, undoing all our written code.
What can we do then ?, well, the solution is as simple as to write another function, after the MAIN() with the source code we want, after that simply change the main module in the project properties, setting the new created function as the new main module, from this point, the Xailer's ID will change the line which creates and show the form for a call to our function, like this:
/*
* Proyecto: Ejemplo1
* Fichero: Ejemplo1.prg
* Descripción: Módulo de entrada a la aplicación
* Autor:
* Fecha: 13/10/2005
*/
#include "Xailer.ch"
//-------------------------------------------------------
Procedure Main()
Application:cTitle :="Ejemplo1"
Application:oIcon :="Icono1"
Empezar()
Application:Run()
Return
//-------------------------------------------------------
Procedure Empezar()
Return
//-------------------------------------------------------
Now we can write the code we want, for example to show a "splash" window (the one that holds an image), may be we can use this function to load values from a INI file, show a dialog for the user and password, etc. and after all of that, show the main form, if it exist.
In the next article you will see how easy this task can be perform and you will a "live" simple example.
1 Comments:
These articles are great for an English-speaking Xailer newbie! Thank you so much for taking the time to help us out with the basics!
Post a Comment
<< Home