Advertisment

Writing Applications for Windows Mobile 6

author-image
PCQ Bureau
New Update

Microsoft released the first version of Windows CE, almost 15 years back,

initiating a long journey into the development of operating systems for embedded

devices. Over the years, Windows CE has evolved into a component based,

embedded, real time operating system with wide ranging applications for mobile

devices and automotive systems. The Windows CE operating system features a

kernel developed specifically for embedded devices and is not a cut down version

of desktop operating systems.

Advertisment

The Windows CE operating system is a superset from which various operating

systems for specific uses are derived. For Mobile devices, the derived operating

system is called Windows Mobile (earlier versions include Pocket PC, Smartphone,

etc). The latest release is Windows Mobile 6, which is powered by Windows CE

5.0.

Recently, we saw many mobile phones running on Windows CE 6 being released.

The latest additions include HTC Touch Diamond, Samsung Omnia, and LG Incite.

These phones offer Office Mobile, Outlook Mobile, Internet Explorer and a host

of other features which make them a virtual replacement of your PC or Laptop

while on the move. The best part of Windows Mobile environment is its similarity

to the widely used Windows XP desktop operating system, which makes these

PDA-phones extremely user friendly. Seamless connectivity to the Microsoft

Exchange Server makes Windows Mobile-based phones quite popular among high

flying executives.

Developing applications for Windows Mobile 6 devices is pretty straight

forward as tools include the popular Visual Studio 2005, .NET Compact Framework

(which is a subset of the desktop .NET Framework) and Windows Mobile 6 SDK, are

available for download from Microsoft. In this article, we will setup the

development environment on a Windows XP PC and create a simple application using

the Windows Mobile 6 Professional SDK.

Advertisment

Direct Hit!

Applies To: Windows Mobile app developers



USP: Learn to create innovative apps for
Windows Mobile-based devices



Primary Link:
www.microsoft.com  /windowsmobile





Keywords: Windows mobile 6

Requirements and downloads



The minimum hardware requirements include:


a. 1 GB HDD space, 1 GB RAM


b. 2 GHz Pentium 4 CPU

Software requirements include:



a. Windows XP or Vista (I tested on Vista Ultimate).


b. Visual Studio 2005 Standard Edition or above (Express edition is not
supported). SP1 is required. The Standard Edition, limited period license is

available from http://tinyurl. com/ 6u66kc.



c. Microsoft .NET Compact Framework v2 SP2. This is free and can be downloaded
from http://tinyurl.com/ 2vlmqu.



d. Windows Mobile 6 Professional SDK. This is also free and installs as an
add-on to Visual Studio 2005. Download from http://tinyurl.com/ynnbzo.



e. Active Sync for Windows XP or Windows Mobile Device Center for Windows Vista.
Both are free. Download ActiveSync from http://tinyurl.com/ 63jjdx and WMDC from

http:// tinyurl.com/652szj.




Advertisment

Installation



Install Visual Studio 2005, followed by the Microsoft .NET Compact Framework.
Install the SDK and the Active Sync/Windows Mobile Device Center.

Figure 1 New Project

Creating a Win32 Project



Start Visual Studio 2005 and select FileÔ New Ô Project. The dialog box shown in
Figure 1 will be displayed. Make the following selections and click 'OK':



Project Type: Smart Device


Templates: Win32 Smart DeviceProject


You can change the following as per your requirements. In my case, the choices
are:



Name: PCQ_App


Location: D:\Project


Solution Name: PCQ_App


Create directory for solution: Yes






Advertisment

This will start the Win32 Smart Device Project Wizard. Click 'Next' to go to

the Platforms page and follow the steps:



1.Use the '<' button to remove Pocket PC 2003 (or any other items) listed under
'Selected SDKs.'



2.Click on 'Windows Mobile 6 Professional SDK' in the 'Installed SDK' list.


3.Use the '>' button to add 'Windows Mobile 6 Professional SDK' to 'Selected
SDKs' list.



Click 'Next' to go to Project Settings page. Select 'Application Type' as
'Windows Application' and leave everything else deselected. Click Finish to

complete the Wizard. This will create the application framework with all

necessary files. It will also open the 'PCQ_App.cpp' source file.



Figure 2 PCQ Application

Modifying the Code for Win32 Application



Search for the function WndProc() and locate the following lines:

Advertisment

case WM_PAINT:



hdc = BeginPaint(hWnd, &ps);


// TODO: Add any drawing code here...


EndPaint(hWnd, &ps);

Insert the following code after the 'TODO' comment line:

int bRet;



TCHAR szText<20>;


StringCchCopy(szText, 20, L"PCQ Hello World App");


SetTextColor (hdc, RGB(255,0,0));


bRet = ExtTextOut (hdc, 60, 100, 0, NULL,


szText, lstrlen(szText), NULL);



Advertisment

From the Menu select Build Ô Build Solution. If everything has been done

correctly, then you will see the following message in the output box:

===Build: 1 succeeded, 0 failed, 0 up-to-date, 0

skipped ====

Figure 3 Windows Mobile 6

Desktop
Advertisment

Running the Win32 Application



To execute the application using the Windows Mobile Emulator, from the Menu
select Debug Ô Start Without Debugging. This will bring up the Emulator as shown

in Figure 2 and run your program to display the message “PCQ Hello World App”.

Once you click 'OK', you will see the Windows Mobile 6 desktop —



Figure 3.

Figure 4 New Project - MFC

Application

Creating an MFC Project



Start Visual Studio 2005 and select File Ô New Ô Project. The dialog box shown
in Figure 4 will be displayed. Make the following selections and click 'OK':



Project Type: Smart Device


Templates: MFC Smart Device


Application.


You can change the following as per your requirements. In my case, the choices
are:



Name: PCQ_MFC_App


Location: D:\Project


Solution Name: PCQ_MFC_App


Create directory for solution: Yes







This will start the MFC Smart Device Application Wizard. Click 'Next' to go

to the Platforms page and follow the steps as given in the Win32 section for

selecting the Windows Mobile 6 Professional SDK. Click 'Next' and follow steps





given for each of the following dialog boxes:

  • Application Type — No Change — Click 'Next'
  • Document Template Strings — No Change — Click 'Next'
  • User Interface Features — change 'Command Bar' to 'Menus and Buttons' —

    Click 'Next'
  • Advanced Features — Click 'Finish'

This wizard will generate all necessary files and resources.

Figure 5 PCQ MFC Application

Modifying the Code for MFC Application



Search for the function CPCQ_MFC_AppView::OnDraw() in the file
PCQ_MFC_AppView.cpp and locate the following lines:

CPCQ_MFC_AppDoc* pDoc = GetDocument();



ASSERT_VALID(pDoc);

// TODO: add draw code for native data here

Insert the following code after the 'TODO' comment line:

CString szText("PCQ Hello App - MFC");



CRect rect;


rect.left = 20;


rect.top = 30;


rect.right = 150;


rect.bottom = 50;







pDC->DrawTextW( szText, rect, 0);

From the Menu select Build Ô Build Solution. If everything has been done

correctly, you will see the following message in the output box:

===== Build: 1 succeeded, 0 failed, 0 up-to-date, 0

skipped =====

Figure 6 Excel Mobile

Executing the MFC Application



To execute the application using Windows Mobile Emulator, from the Menu select
Debug Ô Start Without Debugging. This will bring up the Emulator as shown in

Figure 5 and run your program to display the message “PCQ Hello App - MFC”.

Once you click the 'X' on the top right corner, you will see the Windows

Mobile 6 desktop. You can explore the Windows Mobile 6 features such as Office

Mobile. Click on Windows logo on the top left corner and select Office Mobile.

Click on Excel Mobile and you'll see the screen as in Figure 6.

Note: Clicking on 'X', does not usually 'exit' the application. It just

closes the application window. So, if you want a re-test, close the Emulator and

run the application again.

Deploying applications on Windows Mobile devices



The process of deploying applications on Windows Mobile devices requires the
creation of a Cabinet (.cab) file. This CAB file can be installed through the

Active Sync/Windows Mobile Device Center tools. The complete process is given

online on the MSDN website. You can check the same at

http://tinyurl.com/773zkp.

Conclusion



Windows Mobile is being promoted heavily by Microsoft and various OEMs. The
platform provides a very rich set of tools, APIs, libraries, frameworks and

middleware, which is a subset of Microsoft technologies available on the

Desktop. There is a large section of developers with a strong expertise in

Microsoft technologies on Desktops, who can easily use the development tools,

SDK and Emulator provided for Windows Mobile to learn the differences and create

amazing applications for mobile devices running Windows Mobile 6.

This is an opportunity for developers to have a lot of fun while developing

expertise at the same time in the fast growing mobile device arena. They can

develop applications in their spare time and make them available for download

through websites such as Download.com (http://www.download.com/ mobile/). They

would get valuable feedback and if the application is a hit, they can make money

too.

Advertisment