Windows CE Interface

From Lazarus wiki
Revision as of 21:42, 12 April 2006 by Msmat (talk | contribs) (Debbuging Windows CE software on the Lazarus IDE)

Windows CE interface is in early development.

Setting Up the Windows CE interface

The Compiler and Run-time library for Windows CE are only available on the development branch of Free Pascal, the 2.1.x version. Lazarus snapshot comes with this Free Pascal version.

1 - To start with you will need to recompile the compiler on Windows to create a Windows CE - ARM Crosscompiler. There are instructions here: WinCE_port.

2 - You also need to compile FCL (Free Component Library) with the newly built compile. Instructions here.

3 - Put the batch file bellow on the root of your subversion lazarus directory and run it

make lcl LCL_PLATFORM=wince PP=ppcrossarm.exe CPU_TARGET=arm OS_TARGET=wince

This should compile LCL for Windows CE.

4 - Now you can compile simple LCL software using scripts similar to this:

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

Debbuging Windows CE software on the Lazarus IDE

You can also debug applications created whithin Lazarus IDE.

In Lazarus IDE go to the menu Environment->Debugger Options. Change the debugger path to the directory with gdb for wince.

Also becouse whenever you try to run your application Lazarus tries to build it for Windows, go to the menu Project->Compiler options. In the "Compilation" tab put your .bat file or command which you use to build your application in execute after command just with run checkbox turned on. Now whenever you try to debug your application gdb for wince is launched with your compiled .exe file.

Some Hints :

If you are using Microsoft Device Emulator Preview, select a path for shared folders in emulator, add copy command to your .bat file used for building your application to copy compiled exe file to your shared path and copy that file with File Explorer in emulator to \gdb directory.(just ctrl+c on that file,go to \gdb directory and after each build just do ctrl+v)

Because of currently huge file sizes created with fpc it takes a long time for gdb to move your file into destination directory, by doing this you will save a lot of time. There might be a setting to change default behavior of gdb for copying exe file to \gdb path if so, that'll be best to be used with shared path.

Call stack window seems not to working and will cause an exception.

Road map for the Windows CE interface

currently implemented components with their status

Moved here: Road_To_1.0#Widgetset_dependent_components

components scheduled to be implemented

  • TCanvas
  • TBitmap - Needs a description of the internal format used by Windows CE
  • TPixmap
  • TIcon


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

Second laz wince.PNG 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)
   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;

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.