Click here to Skip to main content
15,867,851 members
Articles / Desktop Programming / MFC
Article

Resizeable Wizard97 style Wizards

Rate me:
Please Sign up or sign in to vote.
2.55/5 (7 votes)
28 Jul 2001CPOL4 min read 164.8K   3.1K   41   27
Property sheet and page classes for resizeable Wizard97 style Wizards

Resizable wizard image

Background

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 (CWizard) and page (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:

Resizable wizard image

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 CBitmapDialog class, CWizard now paints the header bitmaps, and CWizardPage 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 Wizard97 sample (renamed as CNGWizard and CNGWizardPage respectively).

The demo project compiles quite happily at warning Level 4; ANSI and Unicode builds are supported.

Usage

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:

  1. Derive your wizard sheet class from CNGWizard, and your page classes from CNGWizardPage

  2. 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)

  3. Set CNGWizard::m_bResizeable in the constructor of your wizard sheet class if you want your wizard to be resizeable

  4. 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)

  5. 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)

  6. Create your pages and add them to the wizard. CNGWizard will 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 OnInitDialog() and OnSetActive() overrides in your pages will be called earlier than they may expect. To prevent this causing problems, CNGWizardPage has an IsInitialising() method which derived classes can use to determine whether this is the case:

    BOOL CInterior1::OnInitDialog()
    {
    	CInterior1_BASE::OnInitDialog();
    
    	if (IsResizeable())
    	{
    		// Add: id, left, top, width, height
    		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 );
    	}
    	return TRUE;
    }
    
    BOOL CInterior1::OnSetActive()
    {
    	if (!IsInitialising())
    	{
    		EnableWizardButtons(PSWIZB_BACK | PSWIZB_NEXT, TRUE);
    	}
    	return CInterior1_BASE::OnSetActive();
    }

System Requirements and Limitations

  1. Because these classes are based upon the CPropertySheetEx and CPropertyPageEx classes introduced with Visual C++ 6.0, I'm afraid this code will not work with Visual C++ 5.0.

  2. 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.

  3. 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.

  4. In order to correctly repaint the watermark and header bitmaps when the wizard is resized the windows must be created with theCS_HREDRAW and CS_VREDRAW window class styles. Although this should be done by registering a custom window class, CNGWizard::OnInitDialog() currently just modifies the global style using the Platform SDK function SetClassLong().

Finally...

...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 andy.metcalfe@lineone.net.

License

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


Written By
Founder Riverblade Limited
United Kingdom United Kingdom
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...Laugh | :laugh:

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!

Comments and Discussions

 
GeneralPlease Help Me! Pin
Red1_KM11-Jun-06 4:28
professionalRed1_KM11-Jun-06 4:28 
GeneralRe: Please Help Me! Pin
Chris Losinger11-Aug-06 4:44
professionalChris Losinger11-Aug-06 4:44 
Generaldoes not run on windows 98 Pin
emmi4-Apr-06 21:47
emmi4-Apr-06 21:47 
GeneralActually, it does - if you have the right version of comctl32.dll Pin
Anna-Jayne Metcalfe5-Apr-06 11:29
Anna-Jayne Metcalfe5-Apr-06 11:29 
GeneralHeader image Pin
Geert van Horrik15-Apr-05 3:12
Geert van Horrik15-Apr-05 3:12 
GeneralRe: Header image Pin
Anna-Jayne Metcalfe23-Nov-05 5:23
Anna-Jayne Metcalfe23-Nov-05 5:23 
GeneralThanks.. Pin
Monty21-Apr-04 19:19
Monty21-Apr-04 19:19 
GeneralRe: Thanks.. Pin
Anna-Jayne Metcalfe6-Apr-04 11:11
Anna-Jayne Metcalfe6-Apr-04 11:11 
GeneralOnWizardBack(), OnWizardNext(), etc. Pin
Blake Miller16-Oct-03 11:12
Blake Miller16-Oct-03 11:12 
GeneralRe: OnWizardBack(), OnWizardNext(), etc. Pin
Anna-Jayne Metcalfe20-Oct-03 11:50
Anna-Jayne Metcalfe20-Oct-03 11:50 
GeneralRe: OnWizardBack(), OnWizardNext(), etc. Pin
Blake Miller21-Oct-03 8:45
Blake Miller21-Oct-03 8:45 
GeneralRe: OnWizardBack(), OnWizardNext(), etc. Pin
Anna-Jayne Metcalfe21-Oct-03 9:04
Anna-Jayne Metcalfe21-Oct-03 9:04 
QuestionHow to add a Minimum and Maximum button into Property sheet?? Pin
LesleyLiang10-Feb-03 16:20
LesleyLiang10-Feb-03 16:20 
QuestionHow do i Set to Read Only MultiLine Edit Box? Pin
4-Jul-02 17:09
suss4-Jul-02 17:09 
QuestionHow about a "SetSideBanner" Pin
3-Jul-02 1:49
suss3-Jul-02 1:49 
AnswerRe: How about a "SetSideBanner" Pin
Anna-Jayne Metcalfe3-Jul-02 6:51
Anna-Jayne Metcalfe3-Jul-02 6:51 
QuestionHow do i add New Button? Pin
23-Jun-02 22:41
suss23-Jun-02 22:41 
GeneralHeader and Sub title problem !!!!!!!!!! Pin
12-Jun-02 17:02
suss12-Jun-02 17:02 
GeneralRe: Header and Sub title problem !!!!!!!!!! Pin
Anna-Jayne Metcalfe18-Jun-02 10:13
Anna-Jayne Metcalfe18-Jun-02 10:13 
QuestionHeaderTitle and subtitle How? Pin
22-Apr-02 0:28
suss22-Apr-02 0:28 
AnswerRe: HeaderTitle and subtitle How? Pin
Anna-Jayne Metcalfe24-Apr-02 12:23
Anna-Jayne Metcalfe24-Apr-02 12:23 
GeneralRe: HeaderTitle and subtitle How? Pin
12-Jun-02 17:00
suss12-Jun-02 17:00 
hi,

Thanks, for ex:
// Interior1.h
i am add the the member
PROPSHEETPAGE m_psp97;

// Interior1.cpp
i am adding the line into the Construstor
CInterior1::CInterior1() : CInterior1_BASE(CInterior1::IDD)
{
m_psp97.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
m_psp97.pszHeaderTitle = _T("This is the title line");
m_psp97.pszHeaderSubTitle = _T("This is the sub-title line");
}

But it cant display in the header and subtitle.. What should i do?.

2. In the Wizare97 model. there are two Bmp is there know. One is IDB_WATERMARK,IDB_BANER. i want to past this two Bmp in the single page. How should i do that?.

..pl. help me very urgent.... i send mail to you. can u help me on this....

thanks a lot.
Rajesh. S Confused | :confused:
GeneralWindows 95 Pin
Andrew Phillips4-Mar-02 16:10
Andrew Phillips4-Mar-02 16:10 
GeneralRe: Windows 95 Pin
Anna-Jayne Metcalfe4-Mar-02 20:17
Anna-Jayne Metcalfe4-Mar-02 20:17 
GeneralRe: Windows 95 Pin
23-Apr-02 18:23
suss23-Apr-02 18:23 

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.