Difference between revisions of "Windows CE Interface/fr"

From Free Pascal wiki
Jump to navigationJump to search
m (exchanged template)
Line 6: Line 6:
 
En raison d'une mauvaise expérience avec le partage de code entre différentes interfaces dans le passé avec les interfaces gtk/gtk2, il a été décidé de commencer avec un code propre à WinCE. Comme les API sont très similaires, une grande partie du code de l'interface WinCE provient de l'interface Win32/64.
 
En raison d'une mauvaise expérience avec le partage de code entre différentes interfaces dans le passé avec les interfaces gtk/gtk2, il a été décidé de commencer avec un code propre à WinCE. Comme les API sont très similaires, une grande partie du code de l'interface WinCE provient de l'interface Win32/64.
  
{{Other Interfaces}}
+
{{Other Interfaces/fr}}
  
 
== Configuration de l'interface Windows CE ==
 
== Configuration de l'interface Windows CE ==

Revision as of 10:19, 1 April 2008

WinCE Logo.png

Cet article s'applique uniquement à Windows CE.

Voir aussi: Multiplatform Programming Guide/fr

English (en) français (fr) 한국어 (ko) português (pt) 中文(台灣)‎ (zh_TW)

Introduction

La mise au point de l'interface Windows CE a été commencé par Felipe Monteiro de Carvalho et s'est poursuivie par Roozbeh et d'autres contributeurs. L'interface a commencé en 2006 avec un compilateur FPC pour Windows CE encore en développement. Une version stable du compilateur a été réalisée en 2007, ce qui a rendu possible de réaliser une extension (add-on) pour WinCE avec la version 0.9.24 de Lazarus.

En raison d'une mauvaise expérience avec le partage de code entre différentes interfaces dans le passé avec les interfaces gtk/gtk2, il a été décidé de commencer avec un code propre à WinCE. Comme les API sont très similaires, une grande partie du code de l'interface WinCE provient de l'interface Win32/64.

Autres Interfaces

Tuyaux spécifiques aux plate-formes

Articles sur le développement d'interfaces

Configuration de l'interface Windows CE

Pour configurer l'interface Windows CE, vous devez soit utiliser vous devez soit utiliser l'installateur d'extension, soit configurer l'interface manuellement. Les deux options sont détaillées ci-dessous. L'utilisation de l'extension est, bien sur, plus simple.

Utilisation de l'installateur d'extension

Avec la première release de Free Pascal pour Windows CE, l'installation d'un environnement de développement pour WinCe n'a jamais été aussi simple.

Guidage pas à pas:

  • Télécharger et installer l'installateur d'extension pour la version Lazarus téléchargée. Il est situé sur la même page SourceForge.
  • Vous pouvez maintenant compiler des applications Win32 et des applications arm-wince à partir de Lazarus en modifiant les options du compilateur:
    • Widget set: wince
    • Target OS: wince
    • Target CPU: arm

Configurer manuellement l'interface Windows CE

traduction approximative - je n'ai pas essayé cette procédure -

Alors que la version 0.9.24 a été réalisée avec la version 2.2.0 stable du compilateur FPC pour windows CE, la version de développement de Lazarus requiert maintenant la version 2.2.1 ou ultérieure de FPC. Vous trouverez ici les instructions pour mettre à jour cet environnement :

Etape 1 - Pour commencer, vous devez recompiler le compilateur pour Windows pour créer un "cross-compilateur" Windows CE- ARM. Les instructions sont ici : WinCE port.

  • Créer alors un script comme celui pour construire votre compilateur à partir de la version FPC 2.2.0 installée (aussi bien à partir de Lazarus que d'une installation séparée):
cd compiler
PATH=C:\Programas\lazarus220\fpc\2.2.0\bin\i386-win32
make cycle CPU_TARGET=arm OS_TARGET=wince
cd ..
pause

Etape 2 - Vous avez besoin de compiler FCL (Free Component Library) avec la nouvelle compilation. Instructions ici.

  • Cet astucieux script rend cela plus facile (ne pas oublier de mettre les chemins correspondants à votre machine). OPT="-FU... placera toutes les unités au même emplacement, ce qui est très pratique. :
cd packages
PATH=C:\Programas\lazarus220\fpc\2.2.1\bin\i386-win32
make clean all CPU_TARGET=arm OS_TARGET=wince PP=ppcrossarm.exe OPT="-FUC:\Programas\lazarus220\fpc\2.2.1\units\arm-wince"
cd ..
pause

etape 3 - placer le fichier script ci-dessous à la racine de votre dossier Lazarus et exécuter le :

PATH=C:\Programas\lazarus\pp\bin\i386-win32;c:\Programas\arm
make lcl LCL_PLATFORM=wince PP=ppcrossarm.exe CPU_TARGET=arm OS_TARGET=wince

Cela devrait compiler LCL pour Windows CE.

Etape 4 - "Cross-compiler" le LazarusPackageIntf et vous pourrez utiliser les composants visuels de la 3rd party. aller dans lazarus\packager\registration et faire:

PATH=C:\Programas\lazarus\pp\bin\i386-win32;c:\Programas\arm
make PP=ppcrossarm.exe CPU_TARGET=arm OS_TARGET=wince

NOTE: vous devez spécifier dans votre chemin vers les unités des projets $(LazarusDir)\packager\units\$(TargetCPU)-$(TargetOS)\ (ajouter FCL devrait faire cela).

Etape 5 - Maintenant, vous pouvez utiliser l'IDE Lazarus pour définir, compiler et déboguer votre application.

  • Vous pouvez aussi utiliser des scripts similaire pour complier vos applications:
PATH=C:\Programas\lazarus\pp\bin\i386-win32;c:\Programas\arm
ppcrossarm.exe -Twince -FuC:\Programas\fpc\rtl\units\arm-wince -FDC:\Programas\arm -XParm-wince- test.pas
ppcrossarm.exe -Twince -FuC:\programas\lazarus\lcl\units\arm-wince -FuC:\programas\lazarus\lcl\units\arm-wince\wince -FuC:\Programas\fpc\rtl\units\arm-wince -FDC:\Programas\arm -XParm-wince- windowtest.pas

Compiler un projet Windows CE avec l'IDE Lazarus

REMARQUE : récemment, un fichier "wincemenures.or" est indiqué manquant lors de l'édition de lien (linking). Vous devez juste copié ce fichier de "lazarus/lcl/interfaces/wince" vers "lazarus/lcl/units/arm-wince" et tout devrait alors fonctionner.

Tout fonctionne comme avec les autres interfaces et OS. Vérifier que vous avez bien sélectionner wince dans le champ Type composant graphique (LCL) divers dans l'onglet Chemins du menu Projet > Option du compilateur... et dans l'onglet Code sélectionner WinCE comme OS de destination et arm comme CPU de destination. Vous devez aussi changer le Chemin du compilateur dans le menu Outils > Options d'environnement... pour pointer sur le compilateur ppcrossarm.exe compiler.

L'IDE est maintenant prêt pour compiler vos projet Windows CE.

Débogage d'un logiciel pour Windows CE à partir de l'IDE Lazarus

Vous pouvez aussi déboguer des applications créer avec l'IDE Lazarus.

Etape 1 - Dans l'IDE Lazarus, aller au menu Configuration > Option du débogueur.... Modifier le chemin du débogueur pour pointer sur le dossier où se trouve gdb pour WinCE. Vous pouvez vous procurer ce débogueur ici ftp://ftp.freepascal.org/pub/fpc/contrib/cross/gdb-6.4-win32-arm-wince.zip


Etape 2 - If you are using Microsoft Device Emulator Preview, launch(or restore)it.Make sure you've started emulator with 128mg of ram.Select a path for shared folders in emulator, add copy command to your .bat file used for building your application to copy the compiled exe file to your shared path.(as you can see in my .bat file).Here is a .bat file you can use to launch emulator with 128 of ram.

start deviceemulator.exe ".\ppc_2003_se\PPC_2003_SE_WWE_ARMv4.bin" /memsize 128 /skin 
".\ppc_2003_se\PocketPC_2003_Skin.xml"

After that just do 'save and exit' whenever you want to quit emulator,and launch it again from shortcuts created in your start menu.(the shortcuts with '(restore)').

Step 3 - Run Device Emulator Manager and in available emulators right click on the name of emulator and do cradle.Now Microsoft ActiveSync will be launched.If not in Micrososft ActiveSync Go to the menu File->Get connected.If still ActiveSync doesn't recognize the emulator.Uncradle and Cradle the emulator again.

Step 4 - Copy that file with File Explorer program in your emulator to \gdb directory.If it is your first time running emulator you have to create a gdb directory in 'My Pocket PC' folder which is your root(\) folder.(To make things even faster for your each build,with file explorer go to your shared folder,press ctrl+c in your exe file,go to \gdb folder and each time before you try to debug your application just press ctrl+v)

Step 5 - Now you can safely debug your application.gdb for wince will be launched.it will copy arm-wince-pe-stub.exe to \gdb folder and check if your application.exe file is there and will launch the program. If you encountered an error make sure the \gdb folder is created,arm-wince-pe-stub.exe and you exe file is there.Also most of the times because of big size of exe file you can not copy that into your \gdb file.So you have to call Microsoft Device Emulator Preview with 128mg of ram instead of default 64mg ram.

Some Hints

1. Programs remain in memory still after exiting from them. So you can't overwrite the .exe file. You have to use tools like Process Viewer from Microsoft which remotely shows all processes and allow you to kill them. Or use process killers inside the emulator. Process Explorer is another good option. One can get it from http://madebits.com

2. Each time you are done with debugging your program don't exit from program.Do program Reset and then Debugger reset. Note that sometimes still program remain in memory,so you also have to kill the process too.

Installing and Using the Pocked PC Emulator

1 - You can download a Pocket PC Emulator from Microsoft here. First, download and install the file V1Emulator.zip.

2 - Next, be careful that there is a wrong information on the website. It will say that you need to install the Virtual Machine Network Driver, but the link provided on the website is broken. Instead, download Virtual PC 2007 here. This will install the necessary driver too.

3 - Now, go back to the first website and download and install the efp.msi file

Now you should have a fully functional PocketPC Emulator which can be utilized together with Lazarus to develop applications.

To run a Lazarus application on the emulator you can either use GDB via ActiveSync, or you can also just execute it directly.

Running an application on the emulator

1 - Go the the Windows Programs Menu --> "Windows Mobile Emulator Images" --> "PocketPC"

2 - If you never configured your shared folder for the emulator, do so now, by clicking on the menu File --> Configure once the emulator opens. Set it to a folder where you can access your Windows CE executable created with Lazarus.

3 - On the emulator click: Start --> Programs. Now select "File Explorer". Now select "Storage Card". Navigate until you find your executable and double click it to execute it.

Screenshots

An example of Lazarus+WinCE and the Free Pascal software used to test the cross compiler:

Capture 2.jpg Wince.PNG

How to add a new control

For example TButton.

TButton is defined in lcl/buttons.pp. This is the platform independent part of the LCL, which is used by the normal LCL programmer.

Its widgetset class is in lcl/widgetset/wsbuttons.pp. This is the platform independent base for all widgetsets (qt, carbon, gtk, win32, ...).

It's wince interface class is in lcl/interfaces/wince/wincewsbuttons.pp:

 TWinCEWSButton = class(TWSButton)
 private
 protected
 public
   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
 end;

Every WS class, that actually implements something must be registered. See the initialization section at the end of the wincewsXXX.pp unit:

 RegisterWSComponent(TButton, TWinCEWSButton);


Also notice that DestroyHandle should be implemented to clean up memory utilized by the control.

See Also

Downloads