A reader asked me this week if I had any documentation about creating a control panel application. This topic has been on my list for a year, so I maybe it is time to write about it.
I only write code from a clean sheet of paper when I can’t find a good starting point. Luckily for me, this is a case where I can find a good starting point. I am going to start with one of the sample control panel applets available in the shared source code that comes with Platform Builder. I am also going to build this code using Platform Builder, so I will use a sources file, but it shouldn’t be that difficult to take this information and create an eVC or Visual Studio project if you aren’t using Platform Builder.
For this Control Panel Applet, I am going to create one that will display OEM specific versions. These versions will include the bootloader version, CPLD version and OS build number. I am not going to show the code for obtaining these versions because they are specific to the OEM, in this case, me. You would implement the code very different, so it wouldn’t add any value to this article or to you unless you are one of my customers.
The Applet that I will create will be very simple, just a one page dialog with some information and an Okay button.
To explain how to create a control panel applet, I will walk you through the steps that I took to clone and modify the Device Management Control Panel Applet.   At the end, I will provide the source code for my Applet which might be easier to work with because it is a very simple little Applet.
The Device Management Applet is made up of four pages that are dynamically displayed depending on certain information available to it. The user can use a Next and Back button to move around.   I don’t need all that, so I will end up deleting a lot of code.
The steps that I followed are:
1.       Copy %_WINCEROOT%\PUBLIC\WCESHELLFE\OAK\CTLPNL\DMPNL to my platform’s Src\ControlPanel\VersionCPL
2.       Open a build window (see Platform Builder: Build Tools, Opening a Build Window ) and run sysgen_capture –p wceshellfe dmpnl. This will create a file named sources.dmpnl in the current folder.
3.       Merge the Src\ControlPanel\VersionCPL\sources file with the sources.dmpnl to create a sources file that will build the source code and produce VersionCPL.cpl, the Applet. I am not going into the details, but the sources file is available to with the source code download.
4.       Change the file names from dmpnl.* to VersionCPL.* so the code looks like my Applet instead of the Device Management Applet. The source file needs corresponding changes.
5.       Change the icon so that I know that I am running my Applet.   To do this I opened the VersionCPL.ico file in Visual Studio and modified it, don’t miss that there are two sizes of the icon in the file.
6.       Build and test. This is what I did:
a.       Launched an OS
b.      Build the Applet
c.       Copy the Applet to the \Windows folder on the device
d.      Open the Control Panel
e.      Checked that the icon was correct
f.        Tried to open the Applet. This step failed because my OS didn’t have support for Device Management.
7.       Modify the source code to remove the unnecessary code. This was the biggest part of the job, mainly because there was a lot of code to carefully delete.
a.       VersionCPL.cpp – I deleted a lot of code and changed names so that in the future it is readable as a version Applet instead of Device Management.
b.      VersionCPL.h – this file was useless, all that it contained was include statements. So I moved those to VersionCPL.cpp and deleted the h file.
c.       VersionCPL.rc – again I deleted the unnecessary code
d.      Resource.h – more deleting
8.       Modify the source code to add the version information.
a.       VersionCPL.rc – I manually edited this file to add static text fields and text boxes for the versions. I removed Next and Back buttons and included an Okay button. These simple modifications aren’t too difficult to manually change, but you might want to use a resource editor for more complicated changes. I also changed strings to meet my needs.
b.      VersionCPL.cpp – added code to write the versions to the text boxes
c.       Resource.h – added macros for the new fields in the box
9.       Build and test again. It is necessary to close the Control Panel before changing the VersionCPL.cpl file for the changes to take effect. The Version Applet looks like this:
 
Now I have a simple Control Panel Applet that I can use as a starting point for creating other Applets.
Copyright © 2009 – Bruce Eitman
All Rights Reserved