Windows Mobile Developer Network Forum

Windows Mobile Developer Network Forum
It is currently Fri Sep 03, 2010 10:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 

Rate this article
1 0%  0%  [ 0 ]
2 0%  0%  [ 0 ]
3 0%  0%  [ 0 ]
4 0%  0%  [ 0 ]
5 0%  0%  [ 0 ]
Total votes : 0
Author Message
 Post subject: Creating Control Panel Applet
PostPosted: Thu Oct 28, 2004 4:48 pm 
Offline
Site Admin

Joined: Sun Mar 30, 2003 4:04 pm
Posts: 1004
<h2>Introduction</h2> Pocket PC contains <i>Settings</i> item in Start menu that is similar to Control Panel on desktop computers. We will call in Control Panel in this article because <i>Settings</i> is only interface name. This article describes how to create your own applet in Control Panel.
<h2>What You Need</h2> <ul> <li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F663BF48-31EE-4CBE-AAC5-0AFFD5FB27DD">Microsoft eMbedded Visual C++ 3.0</a>
</li> <li><a href="/libraries/STControlPanelApplet_SampleApplication.zip">Sample Control Panel Applet</a> (51 Kb)</li> </ul>
<h2>Background</h2> Control Panel applets are handled by special dynamic linked libraries that have <i>.cpl</i> extension and export one function <i>CPlApplet</i>. This function should have the following interface:
Code:
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 (<i>CPL_INIT</i>, <i>CPL_GETCOUNT</i>, <i>CPL_NEWINQUIRE</i>, etc). These messages are defined in <i>cpl.h</i> header file.
You could have several Control Panel applets in one library (<i>.cpl</i> file). To install <i>.cpl</i> it's enough just copy it to <i>\windows</i> folder.
<h2>Create Control Panel Applet step by step</h2>
<h3>Step 1. Create project</h3> Use "WCE MFC AppWizard (dll)" to create dynamic linked library with MFC support. Choose settings that are suggested by default.
<h3>Step 2. Change extension</h3> You should change extension of output file from <i>.dll</i> to <i>.cpl</i>. Go to <i>Project Settings</i> (Alt+F7), to <i>Link</i> tab page and change extension of the output file name for each configuration.
<h3>Step 3. Add CPlApplet function to exports</h3> Open <i>.def</i> file of your project and add new line with <i>CPlApplet</i> string just after EXPORTS. Like on this picture:<br> <img alt="Add CPlApplet function to list of exports" src="/articles/images/exports.gif" class="dataimage" width="472" height="275">
<h3>Step 4. Define CPlApplet function</h3> Include <i>cpl.h</i> file that contains necessary constants.
Add <i>APlApplet</i> function into your library .cpp file like
Code:
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;
}

<h3>Step 5. Initialization</h3> Write <i>CplInit</i> function where you will do necessary initializations.
<h3>Step 6. Describe your applet(s)</h3> You should write 2 functions <i>CplGetCount</i> and <i>CPL_NEWINQUIRE</i> 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 <i>NEWCPLINFO</i> structure for each applet. This structure contains information about applet name and icon.
<h3>Step 7. Show applet</h3> Most probably you will use dialog for your Control Panel applet. In that case it's enough to call <i>DoModal</i> method of your dialog in <i>CplSelect</i> and <i>CplDblClick</i> functions.
<h2>Using sample</h2> 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 <i>CAppletDlg1</i> dialog class. It's also simple to add more applets in this library. For each applet create description class and dialog using template of <i>CApplet1</i> and <i>CAppletDlg1</i> classes.
<b>Note:</b> 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.
<h2>More information</h2> 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 <i>cpl.h</i> header file that could be found in <i>&lt;Windows CE Tools&gt;\wce300\MS Pocket PC\include</i>.
<h2>Related resources:</h2>
<img src="http://www.pocketpcdn.com/images/bullet.gif" width="22" height="15"><a href="/sections/controlpanel.html">Section: Control Panel</a>
<img src="http://www.pocketpcdn.com/images/bullet.gif" width="22" height="15"><a href="/articles/controlpanel.html">Article: Using Control Panel</a>
<img src="http://www.pocketpcdn.com/images/bullet.gif" width="22" height="15"><a href="/articles/enumerate_cp_applets.html">QA: How can I get information about Control Panel applets like dialog names, icons, etc?</a>
<img src="http://www.pocketpcdn.com/images/bullet.gif" width="22" height="15"><a href="/libraries/stcontrolpanel.html">Library: STControlPanel</a>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group