Sign in Join
Wiki copytemporary

Windows CE Interface: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Introduction
22
33The Windows CE Interface was started by Felipe Monteiro de Carvalho and latter extended by Roozbeh and other contributors. Development of the interface was started in 2006, when the Windows CE FPC compiler was still under development. In 2007 a stable compiler was released, which made it possible to release a WinCE add-on installer for the Lazarus 0.9.24 release.
44
55Because of the bad experience with code sharing between similar interfaces in the past with the gtk/gtk2 interface, it was decided to start a clean code for WinCE. Because the APIs are very similar, a lot of the code of the WinCE interface is copied from the Win32/64 Interface.
66
77## Setting Up the Windows CE interface
88
99To set up the Windows CE interface you will need to either use the add-on installer or set up the interface manually. Both options are described below in detail. Using the add-on installer is, of course, much easier.
1010
1111### Using the stable add-on installer (Recommended Method)
1212
1313With the first stable release of Free Pascal for Windows CE the installation of a WinCE development environment was never easier. The step-by-step guide below is all you need to install and configure Lazarus to compile wince applications.
1414
1515Step-by-step guide:
1616
1717- Install the latest Lazarus on Windows normally from SourceForge: <http://sourceforge.net/project/showfiles.php?group_id=89339>
1818
1919- Download and install the add-on installer (cross-arm-wince) for the same Lazarus version you just downloaded. It's on the same Source Forge Download page.
2020
2121- You can now compile arm-wince application from within Lazarus by changing in the compiler options:
2222 - *Project -\> Project Options -\> Compiler Options -\> Paths -\> LCL Widget Type: wince* or maybe *Project -\> Project Options -\> Compiler Options -\> Paths -\> Select another widget set (Macro LCLWidgetType) --\> Add --\> Set LCLWidgetType --\> Value "wince"*
2323 - ''Project -\> Project Options -\> Compiler Options -\> Config and Target -\> Target OS: wince
2424 - ''Project -\> Project Options -\> Compiler Options -\> Config and Target -\> Target CPU Family: arm
2525
2626- To reduce build filesize, in the *Project -\> Project Options -\> Compiler Options -\> Debugging* section, check *Strip symbols from executable (-Xs)* and uncheck all the rest.
2727
2828### Using the snapshot add-on installer
2929
3030Instead of using the stable release, it's also possible to use the latest development version of the Windows CE interface through the daily snapshot. It's untested, but may be helpful if you need fixes which were added after the latest stable release and consider building everything yourself too hard or too much work.
3131
3232Step-by-step guide:
3333
3434- Install the latest Lazarus snapshot on Windows normally from here. Make sure you choose a Win32 snapshot with the exact same FPC version as the WinCE snapshot: <http://www.hu.freepascal.org/lazarus/>
3535
3636- Download and install the add-on installer for the same Free Pascal version you just downloaded. It's on the same page.
3737
3838- The rest of the steps are similar to the step-by-step guide using the stable add-on installer.
3939
4040### Setting up the Windows CE interface manually
4141
4242To verify which FPC-version can be used with each Lazarus version please check [[LCL Internals|LCL_Internals#Minimum_Toolkit_versions]].
4343
4444Here are instruction to set up the Windows CE interface manually:
4545
4646**Step 1** - To start with you will need to recompile the compiler on Windows to create a Windows CE - ARM Cross-compiler. There are instructions here: [[WinCE port]].
4747
4848- Use TortoiseSVN to checkout the latest 2.2.5: <http://svn.freepascal.org/svn/fpc/branches/fixes_2_2/>
4949
5050- Then create a batch script like this one to build your compiler starting from your installed FPC 2.2.4 (either from Lazarus or from separate install):
5151
5252 cd compiler
5353 PATH=C:\Programas\lazarus220\fpc\2.2.4\bin\i386-win32
5454 make cycle CPU_TARGET=arm OS_TARGET=wince
5555 cd ..
5656 pause
5757
5858**Step 2** - You also need to compile the FCL (Free Component Library) with the newly built compiler. Instructions [[WinCE port|here]].
5959
6060- The following clever batch script makes this easier (don't forget to fix the paths to match those on your machine). OPT="-FU... will put all compiled units on the same place, which is very convenient, (but can cause [problems](http://bugs.freepascal.org/view.php?id=11347). It is better to use a make clean all install instead):
6161
6262 cd packages
6363 PATH=C:\Programas\lazarus220\fpc\2.2.5\bin\i386-win32
6464 make clean all CPU_TARGET=arm OS_TARGET=wince PP=ppcrossarm.exe OPT="-FUC:\Programas\lazarus220\fpc\2.2.5\units\arm-wince"
6565 cd ..
6666 pause
6767
6868**Step 3** - Put the batch file below on the root of your subversion Lazarus directory and run it
6969
7070 PATH=C:\Programas\lazarus22\fpc\2.2.5\bin\i386-win32;c:\Programas\arm
7171 make lcl LCL_PLATFORM=wince PP=ppcrossarm.exe CPU_TARGET=arm OS_TARGET=wince
7272 pause
7373
7474This should compile LCL for Windows CE.
7575
7676**Step 4** - Cross-compile the LazarusPackageIntf in order to be able to use 3rd party visual components. Go to lazarus\packager\registration and do:
7777
7878 PATH=C:\Programas\lazarus22\fpc\2.2.5\bin\i386-win32;c:\Programas\arm
7979 make PP=ppcrossarm.exe CPU_TARGET=arm OS_TARGET=wince
8080 pause
8181
8282NOTE: you need to specify \$(LazarusDir)\packager\units\\\$(TargetCPU)-\$(TargetOS)\\ into your project's unit path (adding FCL as requirement should do that).
8383
8484**Step 5** - Now you can use the Lazarus IDE to design, compile and debug your applications.
8585
8686- You can also use scripts similar to the one below for compiling your applications:
8787
8888 PATH=C:\Programas\lazarus22\fpc\2.2.5\bin\i386-win32;c:\Programas\arm
8989 ppcrossarm.exe -Twince -FuC:\Programas\fpc\rtl\units\arm-wince -FDC:\Programas\arm -XParm-wince- test.pas
9090 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
9191 pause
9292
9393### Compiling Windows CE project files with Lazarus IDE
9494
9595NOTE: recently a "wincemenures.or" file is reported missing on linking. You just need to copy this file from "lazarus/lcl/interfaces/wince" to "lazarus/lcl/units/arm-wince" and everything will be fine.
9696
9797Everything is just as you do with other interfaces and OSes. Make sure you have selected wince as widgetset in in **Compiler Options-\>Paths** and in **Code** tab page select **WinCE** as target os and **arm** as Target CPU.
9898
9999If you compiled your own compiler or installed it without using the Lazarus add-on installer, you also need to change **compiler path** in **Environment options** to point to your ppcrossarm.exe compiler. In other cases the compiler should already be set to the correct one, which is fpc.exe, which is a front end which chooses the correct back end compiler for the target CPU. In this case the path will be similar to C:\lazarus\fpc\2.2.2\bin\i386-win32\fpc.exe varying with the version of your installed FPC.
100100
101101Now, the IDE is ready to compile your files.
102102
103103### Debugging Windows CE software on the Lazarus IDE
104104
105105You can also debug applications created within Lazarus IDE.
106106
107107**Step 1** - In Lazarus IDE go to the menu **Environment-\>Debugger Options**. Change the debugger path to the directory with gdb for wince.you can get it from here <ftp://ftp.freepascal.org/pub/fpc/contrib/cross/gdb-6.4-win32-arm-wince.zip>
108108
109109Also read the notes on <http://bugs.freepascal.org/view.php?id=21061> for information on additional setup.
110110
111111And you also need to have ActiveSync installed for gdb to work. You can get ActiveSync here: <http://www.microsoft.com/windowsmobile/en-us/help/synchronize/activesync45.mspx>
112112
113113**Step 2** - If you are using Microsoft Device Emulator Preview, launch(or restore)it. Make sure you've started emulator with 128MB 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 the emulator with 128 of ram.
114114
115115 start deviceemulator.exe ".\ppc_2003_se\PPC_2003_SE_WWE_ARMv4.bin" /memsize 128 /skin
116116 ".\ppc_2003_se\PocketPC_2003_Skin.xml"
117117
118118After 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)').
119119
120120**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 Microsoft ActiveSync, Go to the menu **File-\>Get connected**. If ActiveSync still doesn't recognize the emulator, Uncradle and Cradle the emulator again.
121121
122122**Step 4 - Optional** - This step is optional and if you don't do it, gdb will do this for you, but it might take some 5 minutes to do it. Copy your executable file with File Explorer program in your emulator to the directory "\gdb". If there is no gdb directory in the root folder, create it.
123123
124124**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 a) make sure the \gdb folder is created and b) that both arm-wince-pe-stub.exe and your .exe file are present. Also most of the times because of big size of a .exe file, you can not copy that into your \gdb file. So, you'll have to call Microsoft Device Emulator Preview with 128mg ram instead of the default 64mg ram.
125125
126126**Known bugs**
127127
128128There are some known issues with debugging, for which some have a work-around. Please read the bug tracker: [1](http://bugs.freepascal.org/view.php?id=21061) and [2](http://bugs.freepascal.org/view.php?id=24126)
129129
130130**Some Hints**
131131
1321321. You can change the remote directory from /gdb to yours by add gdb parameter --eval-command="set remotedirectory ...
133133
134134 --eval-command="set remotedirectory \Storage Card\Program Files\My Program\bin"
135135
1361361. You can reduce the size of .exe file by checking "Use external gdb file debug symbols file -Xg", and "Strip Symbols -Xs", the file myapp.gdb will be generated which can then be used with gdb.
137137
138138### Installing and Using the Pocket PC Emulator
139139
140140#### Windows Mobile 5.0 Emulator
141141
1421421 - You can download a Pocket PC Emulator from Microsoft [here](http://www.microsoft.com/downloads/details.aspx?FamilyId=C62D54A5-183A-4A1E-A7E2-CC500ED1F19A&displaylang=en). First, download and install the file V1Emulator.zip.
143143
1441442 - 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](http://www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&DisplayLang=en). This will install the necessary driver too.
145145
1461463 - Now, go back to the first website and download and install the efp.msi file
147147
148148Now you should have a fully functional PocketPC Emulator which can be utilized together with Lazarus to develop applications.
149149
150150To run a Lazarus application on the emulator you can either use GDB via ActiveSync, or you can also just execute it directly.
151151
152152#### Windows Mobile 6.5 in Windows Vista or superior
153153
1541541 - Download and install the [Microsoft Device Emulator 3.0](http://www.microsoft.com/downloads/details.aspx?familyid=A6F6ADAF-12E3-4B2F-A394-356E2C2FB114&displaylang=en)
155155
1561562 - Download and install the [Windows Mobile 6.5 Developer Tool Kit (with localized Images)](http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=20686a1d-97a8-4f80-bc6a-ae010e085a6e)
157157
1581583 - There is no more ActiveSync in Vista or newer. For newer Windows version it is named "Windows Mobile Device Center. So, download and install it (this download requires the Genuine Windows check):
159159
1601603.1 - For Windows Vista or higher (32-bits): <http://www.microsoft.com/en-us/download/details.aspx?id=14>
161161
1621623.2 - For Windows Vista or higher (64-bits): <http://www.microsoft.com/en-us/download/details.aspx?id=3182>
163163
164164For information about cradling and connecting to a network, read: [3](http://www.petenetlive.com/KB/Article/0000241.htm)
165165
166166##### Connecting the Windows Mobile 6.5 emulator in Vista or Superior to the computer
167167
168168To connect the emulator to the computer, follow these steps:
169169
1701701 - Start the Emulator
171171
1721722 - Start the Device Emulator Manager. Previously it had a nice start menu icon, but in Vista+ it is well hidden. You have to run the file dvcemumanager.exe, which is probably located in C:\Program Files\Microsoft Device Emulator\1.0
173173
174174![](/wiki-images/6/6a/Device_manager.gif)
175175
1761763 - You will see the devices GUID \> Right click it and select "Cradle".
177177
178178![](/wiki-images/a/ae/Cradle.gif)
179179
1801804 - Run the "Windows Mobile Device Center". It should have a start menu icon by now. When it opens, select "Mobile Device Settings" and change the "Allow connections to one of the following" from "Bluetooth" to "DMA"
181181
182182![](/wiki-images/f/f3/Mobile_center_dma.gif)
183183
184184After closing the dialog it should then connect.
185185
186186##### Setting up a shared folder in the emulator
187187
188188The shared folder is a folder in your computer which is mounted in the device with the path "\Storage Card\\" and it works in the device as if it was a memory card. To set this up, click in File -\> Configure in the emulator and set the path to the folder, as shown in the screen shot below:
189189
190190![](/wiki-images/2/27/Wince_emulator_shared_folder.png)
191191
192192#### Links to Emulators and Images
193193
194194##### Emulators
195195
196196[Microsoft Device Emulator 2.0](http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=dd567053-f231-4a64-a648-fea5e7061303)
197197
198198[Microsoft Device Emulator 3.0](http://www.microsoft.com/downloads/details.aspx?familyid=A6F6ADAF-12E3-4B2F-A394-356E2C2FB114&displaylang=en)
199199
200200##### Images
201201
202202[Windows Mobile 6.0 Localized Emulator Images](http://www.microsoft.com/downloads/details.aspx?familyid=38C46AA8-1DD7-426F-A913-4F370A65A582&displaylang=en)
203203
204204[Windows Mobile 6.1 Emulator Images (USA only)](http://www.microsoft.com/downloads/details.aspx?familyid=3D6F581E-C093-4B15-AB0C-A2CE5BFFDB47&displaylang=en)
205205
206206[Windows Mobile 6.1.4 Emulator Images (USA only)](http://www.microsoft.com/downloads/details.aspx?familyid=1A7A6B52-F89E-4354-84CE-5D19C204498A&displaylang=en)
207207
208208[Windows Mobile 6.5 Developer Tool Kit (with localized Images)](http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=20686a1d-97a8-4f80-bc6a-ae010e085a6e)
209209
210210#### Running an application on the emulator
211211
2122121 - Go the the Windows Programs Menu --\> "Windows Mobile Emulator Images" --\> "PocketPC"
213213
2142142 - 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.
215215
2162163 - On the emulator click: Start --\> Programs. Now select "File Explorer". Then select "Storage Card". Navigate until you find your executable and double click it to execute it.
217217
218218## How to add a new control
219219
220220For example TButton.
221221
222222TButton is defined in lcl/buttons.pp. This is the platform independent part of the LCL, which is used by the normal LCL programmer.
223223
224224Its widgetset class is in lcl/widgetset/wsbuttons.pp. This is the platform independent base for all widgetsets (qt, carbon, gtk, win32, ...).
225225
226226It's wince interface class is in lcl/interfaces/wince/wincewsbuttons.pp:
227227
228-` TWinCEWSButton = class(TWSButton)`\
229-` private`\
230-` protected`\
231-` public`\
232-`   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;`\
233-` end;`
228+``` pascal
229+ TWinCEWSButton = class(TWSButton)
230+ private
231+ protected
232+ public
233+ class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
234+ end;
235+```
234236
235237Every WS class, that actually implements something, must be registered. See the initialization section at the end of the wincewsXXX.pp unit:
236238
237-` RegisterWSComponent(TButton, TWinCEWSButton);`
239+```text
240+ RegisterWSComponent(TButton, TWinCEWSButton);
241+```
238242
239243Also notice that DestroyHandle should be implemented to clean up memory utilized by the control.
240244
241245## Gallery
242246
243247Below are screenshots of applications created with Lazarus for Windows CE:
244248
245249Virtual Moon Atlas - A free software for Moon observation or survay ( <http://ap-i.net/avl/en/start> ):
246250
247251![](/wiki-images/b/bc/Vmap1_west_east.jpg)
248252
249253LazCalendar - A simple calendar application:
250254
251255![](/wiki-images/b/b8/Calendar_Wince_App.png)
252256
253257[[germesorders]] - A simple database application using sqlite and RxLib
254258
255259![](/wiki-images/4/41/Germes2.png)
256260
257261[ZzOo](http://deprecated.cocea.biz/blog1.php/2008/08/26/mobile-fun), pronounced /'zi:zu:/, is a free Western Zodiac sign finder. You can install it directly and free of charge on your mobile phone by visiting the [GetJar](http://www.getjar.com/mobile/51934/zzoo/) app store.
258262
259263![](/wiki-images/f/f7/Zzoo-wince.png)
260264
261265[Mini SQLite Viewer](https://sourceforge.net/projects/sqlviewer.minilib.p) - Simple SQlite viewer/manager for WinCE and Win32
262266
263267![](/wiki-images/3/36/MiniSQLiteViewerApp.png)
264268
265269[STAR Manager](http://yk-cv.com/software-developing/?id=starmgr) - advanced system manager that allows to adjust backligth and sound volume of ARM processor-based WinCE device, set desktop wallpapers, controll and manage system pocesses and memory load, contol battery charge and see device configuration.
266270
267271![](/wiki-images/7/7b/Progr-starmgr-1.jpg)
268272
269273### Wireless Orders for Mini Bar Cafe
270274
271275Win32 TCP/IP Application Server, Win32 TCP/IP Client, WinCE TCP/IP Client. Using Lazarus and lNet we develop wireless ordering system for Mini Bar - Cafe. Print receipts directly to Cash Mashine.
272276
273277More Info ( <http://www.cforce.gr/orders.htm> ) Demo ( <http://www.cforce.gr/downloads/setupwodemo.exe> )
274278
275279![](/wiki-images/8/81/Order.jpg) ![](/wiki-images/a/a9/Example.jpg) ![](/wiki-images/c/ca/Table.jpg) ![](/wiki-images/7/7b/Mtrl.jpg)
276280
277281## See Also
278282
279283- [[Windows CE Development Notes|Windows CE Interface Development notes]]
280284- Alternative Lazarus Windows CE tutorial using Win64
281285- [[Roadmap|Roadmap for the Windows CE interface]]
282286- Mini framework for WindowsCE applications: [pkMiniGUI.pas](http://ccrdude.net/files/fpc/pkMiniGUI.pas) [Documentation](http://ccrdude.net/docs/pkCEStuff.htm)
283287- [[KOL-CE|WinCE port of KOL GUI library]] - compact applications for WinCE/Win32.
284288- [[WinCE port]] - About the compiler specific parts of the port
285289
286290---
287291*From the Free Pascal wiki, page "Windows CE Interface", as it stood on 2020-08-09 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
288292Category: WinCE
289293Category: Windows Widgetsets

Back to history