News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

Creating Control Panel Applet

By Vassili Philippov, August 17, 2001.
Print version

Introduction

Pocket PC contains Settings item in Start menu that is similar to Control Panel on desktop computers. We will call in Control Panel in this article because Settings is only interface name. This article describes how to create your own applet in Control Panel.

What You Need

Background

Control Panel applets are handled by special dynamic linked libraries that have .cpl extension and export one function CPlApplet. This function should have the following interface:

LONG CPlApplet(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)

This function works like WindowProc. It handles messages that are sent by Control Panel. There are several messages that could be sent (CPL_INIT, CPL_GETCOUNT, CPL_NEWINQUIRE, etc). These messages are defined in cpl.h header file.

You could have several Control Panel applets in one library (.cpl file). To install .cpl it's enough just copy it to \windows folder.

Create Control Panel Applet step by step

Step 1. Create project

Use "WCE MFC AppWizard (dll)" to create dynamic linked library with MFC support. Choose settings that are suggested by default.

Step 2. Change extension

You should change extension of output file from .dll to .cpl. Go to Project Settings (Alt+F7), to Link tab page and change extension of the output file name for each configuration.

Step 3. Add CPlApplet function to exports

Open .def file of your project and add new line with CPlApplet string just after EXPORTS. Like on this picture:
Add CPlApplet function to list of exports

Step 4. Define CPlApplet function

Include cpl.h file that contains necessary constants.

Add APlApplet function into your library .cpp file like

LONG CPlApplet(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); switch (msg) { case CPL_INIT: return CplInit(hwndCpl, msg, lParam1, lParam2); case CPL_GETCOUNT: return CplGetCount(hwndCpl, msg, lParam1, lParam2); case CPL_SELECT: return CplSelect(hwndCpl, msg, lParam1, lParam2); case CPL_DBLCLK: return CplDblClick(hwndCpl, msg, lParam1, lParam2); case CPL_NEWINQUIRE: return CplNewInquire(hwndCpl, msg, lParam1, lParam2); case CPL_IDNAME: return CplIdName(hwndCpl, msg, lParam1, lParam2); } return 0; }

Step 5. Initialization

Write CplInit function where you will do necessary initializations.

Step 6. Describe your applet(s)

You should write 2 functions CplGetCount and CPL_NEWINQUIRE that describes your applet(s). The first function should return number of Control Panel applets handled by your library. The second function should fill a NEWCPLINFO structure for each applet. This structure contains information about applet name and icon.

Step 7. Show applet

Most probably you will use dialog for your Control Panel applet. In that case it's enough to call DoModal method of your dialog in CplSelect and CplDblClick functions.

Using sample

It's very easy to create Control Panel applet using sample for this article. You will need just edit icon and in name in resources and add your functionality in CAppletDlg1 dialog class. It's also simple to add more applets in this library. For each applet create description class and dialog using template of CApplet1 and CAppletDlg1 classes.

Note: that the Control Panel caches the applets so if you opened the Control Panel before you copy new applet .cpl file it will not apper and you will have to soft-reset the device to refresh Control Panel applets.

More information

For more information read help for CPL_DBLCLK, CPL_EXIT, CPL_GETCOUNT, CPL_INIT, CPL_NEWINQUIRE and CPL_STOP messages. It also costs to explore cpl.h header file that could be found in <Windows CE Tools>\wce300\MS Pocket PC\include.

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House