Click here to Skip to main content
15,880,967 members
Articles / Mobile Apps

Project Wizards for Embedded Visual C++

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
28 Aug 2006CPOL6 min read 48K   15   4
An article on creating Project Wizards for Embedded Visual C++

Introduction

Embedded Visual C++ (EVC) has been around for a while now (it supports Windows CE 2.11 through to Windows Mobile 2003). It's a pretty powerful IDE that is similar to the older versions of VC++ but the most appealing aspect is the price - its free download from Microsoft!

Like most development environments it has eventually been superceeded by the more recent Visual Studio 2003/2005 IDE's. However, for most shareware developers paying for the Standard Edition of Visual Studio 2005 is out of the question and since the Express editions of Visual Studio do not support mobile development, there is little choice left in terms of developing on the Windows Mobile platform unless you stick with the older technoligies. In most circumstances this is fine but the lack of support eventually starts to show.

This article discusses discovering how an obsolete technology works and an easy workaround solution.

Background

Recently, while writing some code to support the Windows Mobile 5 platform from an EVC 3.0 project, I was dreading the fact that I would probably have to make these changes to every new project I write from now on. Obviously this is the ideal case for a Project Wizard to create a standardized project from a code template in a few simple clicks.

Image 1

When talking about wizards, I am refering to the Project Wizards that one would normally find under the Project tab when you start a new project from the IDE.

Armed with no knowledge about the creation of Project Wizards I set out to discover how to create my own wizards.

So, what's in a wizard?

My first port of call was obviously Google. Several fruitless searches later I decided to take a different approach.

The next thing I tried was a simple text search of the words "Hello World" on my hard drive, since the majority of the Pocket PC application wizards create a simple Hello World type application. The search evetually led me to a number of files under (C:\Program Files\Microsoft eMbedded Tools\Common\EVC\Bin\IDE) with an extension of AWX. There were also more of these files located under the individual SDK's such as C:\Windows CE Tools\wce300\MS Pocket PC\Wizards (ie for the original Pocket PC platform).

A quick look at the files in a text editor revealed the fact that these files were binary in nature - so they couldn't simply be edited in a text editor to suit my needs.

Viewing the files in a hex editor I noticed the code generated by the wizard was in fact visible in the file and could be edited to suit but making bulk changes would be hard and cumbersome.

Finally, armed with another clue (the AWX file extension) I performed another search on Google. This time I found the following obscure article (from 1997) relating to the creation of wizards for Visual C++;

http://www.microsoft.com/msj/0397/appwizard/appwizard.aspx

Reading the in-depth article reveals that the correct terminology for a Project Wizard is AppWizard. An interesting fact is that AppWizard files are actually just special MFC DLL files with an AWX extension. To generate them you need to use a wizard to create a special project which (when compiled) will become a new wizard. This is all done from within Visual C++.

So how do you create a wizard for EVC? Well, interestingly there is a wizard to create new wizard's on the second EVC disc (along with the required lib and header file). The wizard only runs in Visual Studio (ie VC++) since it generates an x86 DLL which in turn is run from the EVC IDE.

Searching Google again, this time for AppWizards on Pocket PC, the only documentation I found relating to this wizard was on MSDN under some pre-release documentation for EVC 4.0;

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vcce4/html/evoriCreatingCustomWCEAppWizards.asp

The idea is that you add the header file (customaw.h) and the lib file (mfcapwz.lib) to your VC++ environment. I am led to believe these are different in some way to the copies that already exist in the environment (these files were already available under my VC++ 6 installation). Lastly you need to copy the Windows CE wizard itself, this is the file called "cecustmwz.awx" or "cecust~1.awx" (yes, that is the right name) to your IDE (I placed mine under C:\Program Files\Microsoft Visual Studio\COMMON\MSDev98\Bin\IDE). The name of the AWX file is not important.

When your VC++ IDE is restarted a new wizard called "CE Custom AppWizard" is available. Following the wizard prompts it allows you to create a VC++ project which you can build into a new wizard that can be used in EVC.

Image 2

There obviously is a bit more to the AWX format, for example the $$root$$ macro value (which is a place holder for project name entered from the IDE) but documentation for these kinds of things is almost non-existant (although the MSDN article does cover some of this).

However, generating a simple wizard using the standard approach is easy enough, if you have access to VC6 that is!

So what happens if you dont have access to VC6?

An Alternative Approach

If you recall earlier in the article, AWX files are actually MFC DLL files. The "magic" in the DLL's is actually a resource type called "TEMPLATE." The template type contains all of the raw code used in the template (ie any cpp, h, resources files etc). These resources can be edited or replaced using any resource editor.

Image 3

I won't go into too much deatil on how to use a resource editor since most developers will already be familiar with this. Basically resource editors can be used to swap, extract, edit or delete resources from a compiled DLL or EXE. My favourite resource editor is ResHacker (Resource Hacker) which is an awesome freeware product. Although it hasn't been updated since 2002 its a great application and I find it to be an essential developers tool.

Using ResHacker it is easy to inject new code directly into an existing wizard without having to write your own wizard. This is a quick solution if all you need to do is slightly alter an existing wizard.

If you want a variation of an existing wizard (and to retain the original) you can copy an existing wizard (just a file copy in Explorer) and alter the code as required in ResHacker. The EVC IDE will actually load the second DLL but the description will be the same as the original. The way to fix this is to edit the "ProductName" attribute under the Version Info resource (see screenshot below).

Image 4

Points of Interest

According to this article (http://www.codeguru.com/cpp/v-s/devstudio_macros/customappwizards/article.php/c9647) Visual Studio 2003/2005 wizards for these IDE's are created using DHTML and JavaScript. Hopefully this means the whole process will be bit more transparent when these technologies become obsolete in the future.

Out of interest I did try and compile the code for a Project Wizard in Visual Studio 2003 but this crashed EVC when I attempted to run the wizard.

Deleting, moving or changing the extension of AWX files is an easy way to clean up the number of Project Wizards that show up in the IDE. For instance, I prefer to us WIN32 instead of MFC so I have moved the MFC wizards so that the IDE does not detect them (see screenshot below).

Image 5

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
New Zealand New Zealand
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalcrash Pin
Taulie15-Sep-06 21:04
Taulie15-Sep-06 21:04 
GeneralRe: crash Pin
trevor.hart15-Sep-06 21:52
trevor.hart15-Sep-06 21:52 
GeneralRe: crash Pin
Taulie16-Sep-06 20:12
Taulie16-Sep-06 20:12 
GeneralRe: crash Pin
trevor.hart17-Sep-06 16:07
trevor.hart17-Sep-06 16:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.