Important Update: As was pointed out in the comments, this doesn't always work.  I had the opportunity to begin looking into that today when one of our engineers had the same problem, which is that the dialogs don't show up correctly and sometimes not at all.  After trying several things, what we now think that we know is that editing the RES files in Visual Studio causes the problem, which means Platform Builder 6.0.   Editing the RES files with Platform Builder 5.0 works well.  I know that many of you don't want to hear that becuase you don't have Platform Bulder 5.0 - but for now that is all that have.


Your marketing department just told you to change the look of one of the Control Panel applets.  Of course you didn't write it, Microsoft did, and you don't want to maintain it, you want Microsoft to do that.  but still you need to change the way it looks. The obvious solution to this is to clone the code and start modifying it.  But this solution is a very big hammer for a very small nail.   So there must be an easier way that will also prevent you from needing to maintain the source code.

The easier solution is to modify the res file for the applet.  An of course this also applies to any other Microsoft binary that has a res file.  In fact this can apply to a binary that doesn't have a res file, but we will look at that later.  For this example, the marketing department decided that user were having trouble selecting the "Recalibrate" button on the Stylus applet because the button is too small.  They also want to reduce the text in the dialog to "Press the button".  The default look for a landscape display looks like this:

To get started we need the res file.  If we look around in the Public tree, we will find that the stylus applet is part of cplmain in WCESHELLFE.  Now what we really need is the res file that was processed by sysgen.  This is can be found in the %_FLATRELASEDIR%\<LANGID>,  where LANGID is the numeric id for the language that we are building.  I will use US English which is 0409, so looking in %_FLATRELEASEDIR%\0409 I find the cplmain.res file.  Of course we don't want to edit the file in the release folder, so copy the file to your FILES\0409 folder, your FILES folder is in either your Platform or your project.

Now that we have a copy of the file, open it in Platform Builder, Visual Studio or eVC where you can edit it.  When you open cplmain.res you will see that there are a lot of dialogs, which means that you will need to search for the dialog that you need to modify.  I found the dialog with the "Recalibrate" button at dialog 190, yes they are numbered not named.  This is what it looks like before editing:

 

I changed the static text and the button size to meet my marketing department's requirements:

Next, we need to make sure that our changed cplmain.res is merged with cplmain.cpl.  To do this, edit your plaform.loc or project.loc file to add:

 cplmain

to the file.  This tells makeimg that cplmain needs to be localized.  Part of localization is to merge res files with their binaries.

Since I have already built my project, all I need to do is get this to the _FLATRELEASEDIR.  Let's start by doing it with the build tools.  Run "buildrel", I will explain later why this is relevant.  Now to merge the change to cplmain.res with cplmain.cpl just run makeimg, which will do the merge using res2exe.exe.

Run your new OS image and test.  The Stylus applet should now look like this:

 But, that doesn't meet the marketing requirements of reducing the text to just say "Press the button" does it?  So we need to edit again.  I will leave that to you.  You will find the extra text in the "Strings" of cplmain.res.  But once you make the change, you will want to test it again.  You certainly could run buildrel and makeimg again, but it be faster to just copy the modified cplmain.res to the _FLATRELEASEDIR and run makeimg.  That would work if only makeimg woudn't skip running res2exe.exe the next time, and it will.  To figure out why, look at the makeimg output.  In the output you should find a line that looks like this:

makeimg: Performing localization since C:\WINCE500\PBWorkspaces\MyProject\RelDir\MyBSP_ARMV4I_Release\\prevlc.txt doesn't exist or contains locale different from 0409.

From that we can infer that makeimg leaves a cookie behind to remind it that the res files have already been merged with the binaries.  If we run makeimg again, that line changes to:

makeimg: Localization skipped since locale in c:\WINCE500\PBWorkspaces\MyProject\RelDir\MyBSP_ARMV4I_Release\prevlc.txt is unchanged from 0409.

And res2exe.exe doesn't run to merge the modified res file.  So you can delete prevlc.txt and run makeimg again.  This time the res file will be merged.So, now we can reduce the number of files that need to be maintained by us to modify the look of the user interface of Microsoft's applications and applets.  The same thing can be done with third-party binaries.  Let's say you get an application for your wireless card vendor that doesn't fit your display well.  You can open the exe in Platform Builder.  The file will show like it is a res file and you can save the res file so that you can edit it.  Then just add the file name to the loc file just like we did for cplmain.

 Go to Summary of Building Windows CE

Copyright © 2008 – Bruce Eitman
All Rights Reserved