A year or so ago I implemented a wizard for the calibration of positions
of arrays of acoustic beacons on the seabed, as part of our Pharos
acoustic positioning application.
After doing a little research, I proposed that we use the (then relatively
new) Wizard97 style to implement it, to give it more visual impact. To this
end, I implemented MFC classes for a wizard sheet (
CWizardPage). Although most of the pages were conventional,
one of them contained a Chart view (with an associated document) within a frame
window, complete with two toolbars:
This page introduced a problem. To make it useable it really needed to be bigger
- or, even better, resizeable. Unfortunately, at the time we had higher priorities
so resizing stayed firmly on the "to do" list.
The breakthrough came with the publication of Herbert Menke's CResizeCtrl
on Code Project, which we started using to support resizeable dialogs and property
pages elsewhere within the project. In due course, the inevitable happened, and
we implemented another Wizard.
Unfortunately, when we integrated
CResizeCtrl into the new wizard,
the Wizard97 style appeared to be incompatible with resizing - the watermark
and header bitmaps failed to paint correctly. As a result, the new wizard was
implemented with the Wizard97 features disabled (we reasoned that we could always
paint them ourselves if we couldn't find a solution later).
I've now finally got around to doing just that. Using code from Joerg Koenig's
CWizard now paints the header bitmaps, and
the watermarks. I had to make some minor changes to CResizeCtrl
to accommodate wizard pages with header bitmaps, but other than that it worked
pretty much first time.
To demonstrate these classes I've incorporated them into the Microsoft
sample (renamed as
The demo project compiles quite happily at warning Level 4; ANSI and Unicode
builds are supported.
Before implementing your own Wizard97 classes, it's worth reading the
Wizard97 Specification in the Visual C++
Help (its also available on the MSDN website), which contains useful guidelines
for implementing wizards using the Wizard97 style.
Implementing a wizard using these classes is pretty straightforward:
Derive your wizard sheet class from
CNGWizard, and your page
Add an OnInitDialog() override to each page and add the page's
controls to the resizer (see Herbert Menke's CResizeCtrl
article for full details on how to do this)
Set CNGWizard::m_bResizeable in the constructor of your wizard
sheet class if you want your wizard to be resizeable
Set CNGWizard::m_bShowFinishAlways in the constructor of your
wizard sheet class if you want the Next and Finish buttons in
the wizard to both be visible at all times (this can be useful in some wizards)
Initialise your wizard sheet by specifying the watermark and header
bitmaps, together with their display styles (centred, tiled
or stretched for the watermark, and tiled or stretched
for the header)
Create your pages and add them to the wizard.
configure the pages for you as they are added.
Note that each page will be (briefly) activated as it is added to allow the
resizer to initialise properly. A consequence of this is that
OnSetActive() overrides in your pages will be called earlier
than they may expect. To prevent this causing problems,
IsInitialising() method which derived classes can use
to determine whether this is the case:
m_Resizer.Add( IDC_LIST1, 0, 0, 100, 100 );
m_Resizer.Add( IDC_STATIC_DESC, 100, 0, 0, 100 );
m_Resizer.Add( IDC_BUTTON1, 100, 100, 0, 0 );
EnableWizardButtons(PSWIZB_BACK | PSWIZB_NEXT, TRUE);
System Requirements and Limitations
Because these classes are based upon the
CPropertyPageEx classes introduced with Visual C++ 6.0, I'm afraid
this code will not work with Visual C++ 5.0.
On older systems (pre-WinMe/2000) the use of Wizard97 may require an upgrade
to the common controls library (comctl32.dll), since version 5.80 or
later is required to use Wizard97 controls. If your system requires this update,
you can download an installer (50comupd.exe) for the update from the Microsoft
web site at http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp.
According to the Microsoft documentation on Wizard97, Wizard97 controls
will not work correctly on Windows 95 systems. However, when
I ran this sample on a Win95 machine the only problem I could see was that
static controls on pages which had watermarks didn't display correctly (presumably
because transparency doesn't work for static controls on Win95). Apart from
that minor problem, the wizard worked just fine and was perfectly legible.
In order to correctly repaint the watermark and header bitmaps when the
wizard is resized the windows must be created with the
CS_VREDRAW window class styles. Although this should be done
by registering a custom window class,
currently just modifies the global style using the Platform SDK function
...a bit of a plug: if you want to see an example of these classes in action,
check out my Resource ID Organiser
Add-In for Visual C++ which uses these classes to implement a Wizard for
renumbering resource symbols.
If you have any comments, suggestions, bug reports etc. please feel free to
email me at firstname.lastname@example.org.
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing Darth Vader's Codpiece *
for the UK Army in 1990).
* Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for Avionic Test Systems
in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company, Riverblade Ltd
One of my personal specialities is IDE plug-in development. ResOrg
was my first attempt at a plug-in, but my day to day work is with Visual Lint
, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.
I love lots of things, but particularly music, photography and anything connected with history or engineering. I despise
ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...
I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!