issue112:tutoriel2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue112:tutoriel2 [2016/08/31 13:21] – d52fr | issue112:tutoriel2 [2016/09/02 15:20] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
In the first part of this series we installed the required compiler software and developer’s interface. We compiled a simple console-based program and a first Free Vision application. In this second part we will be tuning our Free Vision interface and making it respond to commands.** | In the first part of this series we installed the required compiler software and developer’s interface. We compiled a simple console-based program and a first Free Vision application. In this second part we will be tuning our Free Vision interface and making it respond to commands.** | ||
+ | |||
+ | Dans cette série d' | ||
+ | |||
+ | Dans la première partie de cette série, nous avons installé l' | ||
**Fleshing up the menu | **Fleshing up the menu | ||
Ligne 10: | Ligne 14: | ||
As readers accustomed to Turbo Pascal will have noticed, this is exactly the same syntax. In fact, I would not be surprised to learn that one of my projects from back then would just compile under Free Pascal. That is, if I manage to dig out the 3½” diskettes and a disk drive that still works. Just to refresh memories, let us note that “~” is used to indicate key accelerators, | As readers accustomed to Turbo Pascal will have noticed, this is exactly the same syntax. In fact, I would not be surprised to learn that one of my projects from back then would just compile under Free Pascal. That is, if I manage to dig out the 3½” diskettes and a disk drive that still works. Just to refresh memories, let us note that “~” is used to indicate key accelerators, | ||
+ | |||
+ | Étoffer le menu | ||
+ | |||
+ | Créons un menu sur mesure et rendons-le interactif. Pour ce faire, nous écraserons deux procédures différentes de l' | ||
+ | |||
+ | Nous insérerons une barre de menu basique avec deux sous-menus : un menu « File » (Fichier) avec quelques options standards et un menu « Help » (Aide) avec une option qui ouvrira la traditionnelle boîte de dialogue « About » (À propos) (voir le code ci-dessous). | ||
+ | |||
+ | Comme les lecteurs accoutumés à Turbo Pascal l' | ||
**Responding to events | **Responding to events | ||
Ligne 20: | Ligne 32: | ||
To respond to the cmHelp command, we are using a simple if structure to set up a MessageBox. This is a fast way of creating a message dialog box, that can be of several different types (Information, | To respond to the cmHelp command, we are using a simple if structure to set up a MessageBox. This is a fast way of creating a message dialog box, that can be of several different types (Information, | ||
+ | |||
+ | Répondre aux événements | ||
+ | |||
+ | Le menu préparé au-dessus répondra bel et bien à certains boutons, mais pas à d' | ||
+ | |||
+ | C'est pourquoi nous remplacerons la méthode HandleEvent existante par la nôtre. Par exemple : | ||
+ | |||
+ | Il est particulièrement important d' | ||
+ | |||
+ | Pour répondre à la commande cmHelp, nous utilisons une simple procédure if pour paramétrer une MessageBox. C'est une façon rapide de créer une boîte de dialogue de message, qui peut être de différents types (Information, | ||
**Setting up a file input box | **Setting up a file input box | ||
Ligne 31: | Ligne 53: | ||
FileName is a string to save the user-inputted filename, result will contain the command code of the button chosen (cmOpen or cmCancel), while pOpen is a pointer to the new dialog to be created. Now, within HandleEvent, | FileName is a string to save the user-inputted filename, result will contain the command code of the button chosen (cmOpen or cmCancel), while pOpen is a pointer to the new dialog to be created. Now, within HandleEvent, | ||
+ | |||
+ | Paramétrer une boîte de dialogue de saisie de fichier | ||
+ | |||
+ | Il y a aussi d' | ||
+ | |||
+ | var | ||
+ | FileName: String; | ||
+ | result : integer; | ||
+ | pOpen : PFileDialog; | ||
+ | |||
+ | FileName est une chaîne de caractères pour sauvegarder le nom de fichier saisi par l' | ||
**We have created a new FileDialog object, specifying that we wish to filter files with the ’*.txt’ pattern. When executed, the command chosen by the user is stored in variable result, and can then be examined to control subsequent actions. | **We have created a new FileDialog object, specifying that we wish to filter files with the ’*.txt’ pattern. When executed, the command chosen by the user is stored in variable result, and can then be examined to control subsequent actions. | ||
Ligne 37: | Ligne 70: | ||
However, there are a couple of points to be noted since the last time I stared at one of these, back in the days of MS-DOS. The first is that it seems to handle well a POSIX file system, with the “/” file separator instead of MS-DOS’s idiosyncratic “C:” and “\”. The user can easily navigate through a standard Ubuntu home directory. On the other hand, we can also see that Unicode characters in filenames that do not appear in the common ASCII codepage (codes up to 127) have been altered, specifically the accents in “Música” and “Públic”. This may be a minor problem for some, or major for others if the intended end user’s environment is mostly in a non-latin script. ** | However, there are a couple of points to be noted since the last time I stared at one of these, back in the days of MS-DOS. The first is that it seems to handle well a POSIX file system, with the “/” file separator instead of MS-DOS’s idiosyncratic “C:” and “\”. The user can easily navigate through a standard Ubuntu home directory. On the other hand, we can also see that Unicode characters in filenames that do not appear in the common ASCII codepage (codes up to 127) have been altered, specifically the accents in “Música” and “Públic”. This may be a minor problem for some, or major for others if the intended end user’s environment is mostly in a non-latin script. ** | ||
+ | |||
+ | Nous avons créé un objet FileDialog, en spécifiant que nous souhaitons filtrer les fichiers avec le motif « *.txt ». À l' | ||
+ | |||
+ | La boîte de dialogue obtenue n'a rien de spécial car elle est standard dans Turbo et Free Vision. Elle fonctionne tout simplement et est très réactive. | ||
+ | |||
+ | Cependant, depuis la dernière fois que j'en ai contemplé une, du temps de MS-DOS, il y a deux points à noter. Le premier est qu' | ||
**By this point, we have been using several of Free Vision’s library units, which must be included at the beginning of our program file: | **By this point, we have been using several of Free Vision’s library units, which must be included at the beginning of our program file: | ||
Ligne 43: | Ligne 82: | ||
The complete code for this example is available at http:// | The complete code for this example is available at http:// | ||
+ | |||
+ | À ce stade, nous avons utilisé plusieurs unités de la bibliothèque de Free Vision, qui doivent être incluses au début de notre fichier de programme : | ||
+ | |||
+ | uses App, Objects, Menus, Drivers, Views, Dialogs, MsgBox, StdDlg; | ||
+ | |||
+ | Le code complet de cet exemple est sur http:// |
issue112/tutoriel2.1472642461.txt.gz · Dernière modification : 2016/08/31 13:21 de d52fr