Software Examples

My primary research area deals with Graphical User Interfaces (GUIs) for Computational Electromagnetics (CEM) codes, primarily in the WinTel environment using VC++.  Quite often I wind up trolling the Web for examples to help me deal with a problem, and I am amazed at the number and quality of example programs out there.  These examples are my way of giving something back.

 

Example 1:  PicNamer3, a AppWizard Dialog App using a Customized CFileDialog

We are building a new house, and I have been taking (lots and lots of) digital photographs.  Now, X months later I have over 1000 image files, organized more or less chonologically.  The idea is to have an image record of how all the plumbing, electrical, hvac, and network wiring gets from point A to B through the walls and ceilings, so that when we want to find something or cut into a wall, we can do so intelligently.  Unfortunately, the image filenames aren’t very descriptive, and it would be very easy to wind up in a situation where there are too many images to search effectively, rendering the entire exercise somewhat meaningless.  So, being a hot-shot programmer I decided I’d take a few hours and whip up an app to handle the file renaming task, in a nice, graphical manner.  I had never done a dialog app, and I had never done any serious CFileDialog customization, so I thought this would be a nice opportunity to learn both at once.  Three days and untold hours later, I have something that I think might actually work, and boy have I learned a lot!  Thanks to examples and code from all over the web, but especially to Paul DiLascia’s January 2002 C++ Q&A article (http://msdn.microsoft.com/msdnmag/issues/02/01/c) and examples provided by Rail Jon Rogut (http://home.earthlink.net/~railro/mfc_link.html)

 

PicNamer3 started out life as a plain-vanilla AppWizard dialog application.  Then I added my ‘extra’ controls to the dialog and modified dialog resource properties per the Platform SDK help topics “Open and Save As Dialog Box Customization” and “Explorer-Style Custom Templates”.  After many false starts trying to use a hook procedure to handle my custom controls, I ran across a post by Rail Jon Rogut that explained how to do it another way, as follows:

 

Cheat a little...

 

First create your dialog resource and derive it from CDialog - set up

all your member variables, etc.

 

Then create a dummy class derived from CFileDialog and copy all the

relevent code to change your original class to be derived from

CFileDialg.

 

I've also attached an example project to show how it should look.

 

 Rail

--

 Recording Engineer/Software Developer

 Rail Jon Rogut Software

 http://home.earthlink.net/~railro

 mailto:railro@earthlink.net

 

 

I had already done the first step, so all I had to do was use ClassWiz to create a new class with CFileDialog as the base class, and then compare the two sets (header & cpp) files to see what I had to add to the CDialog-based class to make it look like a CFileDialog-based class.  After making the changes, I then just changed the base class of my original CDialog-derived class to ‘CFileDialog’, and I was mostly home.

 

I still wound up spending a huge amount of time getting everything to work just right, but most of that was unique to the particular application.  When I ‘finished’, I had a working CFileDialog-based dialog app that allowed me to select one or more image files, and bulk rename them using a filename constructed from the selected category (radio buttons), the file creation date (yymmdd), and a sequence number.  The completed dialog is shown below, and the VCC project files (zipped), can be downloaded here

 



Example 2:An MFC AppWizard application demonstrating OpenGL Polygon Tessellation

Recently I had some trouble with malformed polygons in one of my OpenGL scientific visualization workbenches, and I discovered I needed to do something called 'Tessellation'. After some research and lots of help from the folks at comp.graphics.api.opengl, I got an MFC tessellation implementation working, but it wasn't easy and its still not really all that robust.

In any case, while I was researching the problem it became apparent there were a lot of other people out there trying to figure out how to implement polygon tessellation in MFC (particularly how to figure out the OpenGL tessellation callback function calling signatures), and I never did find a working MFC example.

So, I built one from scratch. Starting with a generic MFC Appwizard-generated application, I ported the necessary OpenGL tessellation routines from my other (now working) project and added facilities for generating and displaying a single polygon with one or more contours. I also added the ability to save generated contours in an ASCII .DAT file (MFC's binary serialization routines are nice, but you can't tell if what you wanted to save is what actually got written disk). See the included help file for the .DAT file format.

The project as it stands seems to work fairly well, but there are some known problems, especially with the CombineCallback function. I plan to continue development of this in my spare time, as I find it useful myself to work out problems or learn more about polygon tessellation in particular and OpenGL in general.

A screenshot (ok, the banner page is from another instance) is shown below, and the VC++ V6 MFC project files (zipped), can be downloaded here

MFCTess Application