Re: Sharing code between PocketPC and Windows XP

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Norman Bullen (norm_at_BlackKittenAssociates.com.INVALID)
Date: 08/12/04


Date: Thu, 12 Aug 2004 01:43:38 GMT

Mateusz Łoskot wrote:

> On 8/12/2004 1:31 AM, Richard Coutts wrote:
>
>> Ideally I'd like them both the share the some body of code and just
>> compile for one or the other -- is that possible?
>
>
> Use preprocesor definitios like
>
> #ifndef(_WIN32_WCE)
>
> // code for non-Windows CE system
> #else
>
> // code for other Windows platforms
> #endif
>
> Look at MSDN for what definitions you may use, I give
> above only one example, the _WIN32_WCE identifier.
> Obviously, you have to create project files for eVC++ and
> for "big" VS and add the same source files to those projects.
>
> Greets
>
>

I have a small application that now runs on desktop Windows, Windows CE
(PocketPC) and Palm OS devices. It has a lot of #if defined(...)
statements in it to configure the code for these various platforms. As
you might guess, the Palm OS is the most different and, in some places,
I have essentially two separate streams of code to do more-or-less the
same thing.

In another, older, project I support desktop Windows and Windows CE in
both Palm-Size PC and Pocket PC versions. Because I couldn't in this
case simply use #if defined(_WIN32_WCE) because of the two different CE
platforms, I developed the following paradigm:

For each platform I create a header file named platform.h. In it I
define PLATFORM as DESKTOP, POCKET_PC, etc. and also define other
attributes of the system; the screen size, for example, in the case of
the application that also runs on Palm OS. I put the different
platform.h files in different subdirectories of the main source code
directory (.\desktop\platform.h , .\PocketPC\platform.h ,
.\PalmOS\platfrom.h , etc.) and in the project settings for each of the
different projects I add the appropriate directory as an additional
directory for include files. Every source module, of course, contains
   #include "platform.h"

The major differences, at least for the Windows platforms, have to do
with screen size (your Pocket PC version may need to have scroll bars
where the desktop version does not, or you may have to build your
dialogs differently) and the different support from the shell. (The
Pocket PC shell manages the menu bar for you rather than having it as
part of your application, etc.

You also have to use Unicode in virtually all API calls so you might as
well use it through out the application. This means replacing "char"
with "TCHAR", "LPSTR" with "LPTSTR", and putting _T( ) around all of
your character and string literals.

I believe I've seen a book entitled _Making Windows Mobile_ which, I
think, is about porting desktop Windows code to Windows CE.

Norm

-- 
--
To reply, change domain to an adult feline.


Relevant Pages

  • Re: windows ce emulator visual studio 2008
    ... "For example a Pocket PC application will not run on a Windows CE 3.0 device ... If I chose a Windows CE project in VS, and I intend it to run on Windows CE ... In other words, the emulator should look ... versions of sdks, mobile platforms, sql compact versions are confusing me. ...
    (microsoft.public.windowsce.app.development)
  • Re: Help needed - Determining the Device Type
    ... They are not assumptions for platforms (like the Pocket PCs) Microsoft ... device description like Windows Mobile, Windows Pocket PC, Windows CE Device ...
    (microsoft.public.windowsce.embedded)
  • Re: windows ce emulator visual studio 2008
    ... "For example a Pocket PC application will not run on a Windows CE 3.0 device ... If I chose a Windows CE project in VS, and I intend it to run on Windows CE ... Platforms" in microsoft.public.pocketpc. ... I don't think any Windows CE emulator exists as such. ...
    (microsoft.public.windowsce.app.development)
  • Re: Inserting of dynamically created menus
    ... The version of my code that targets non-Pocket PC platforms runs on ... every Windows CE platform I've tested: HPC, Palm-size PC, HPC Pro, ... Palm-size PC 1.2, HPC 2000, Pocket PC, Pocket PC 2002, STANDARDSSDK, ... >> If you are targeting some other Windows CE platform or are willing to ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Inserting of dynamically created menus
    ... The version of my code that targets non-Pocket PC platforms runs on ... every Windows CE platform I've tested: HPC, Palm-size PC, HPC Pro, ... Palm-size PC 1.2, HPC 2000, Pocket PC, Pocket PC 2002, STANDARDSSDK, ... >> If you are targeting some other Windows CE platform or are willing to ...
    (microsoft.public.windowsce.embedded)