Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wizard in MFC !! (How do I design one?)

110 views
Skip to first unread message

Jessica

unread,
Dec 6, 2007, 6:54:00 AM12/6/07
to
Hello All,

I have to start working on a 'Wizard' which will be developed as an MFC
extension DLL for an existing MFC application.

I was thinking about how the design of the wizard should be. Currently I am
planning to create a dialog, and put all the common UI elements like Next,
Back buttons and a left pane which shows all the steps with the currently
active step highlighted in it.

Now, the main viewing area of the wizard will have to change its contents
based on which step of the wizard the user is currently in. I am planning to
put all the controls which are required in all steps in there, and show/hide
them dynamically when user clicks Next button or Back button.

MFC experts, please comment on this kind of an apporach, and also let me
know if there is a better way around to design a wizard...!

Thanks In Advance!!
Jessy

Check Abdoul

unread,
Dec 6, 2007, 8:28:03 AM12/6/07
to
Take a look at the CPropertySheetEx and CPropertyPage MFC classes.

Cheers
Check Abdoul
---------------------

"Jessica" <Jes...@discussions.microsoft.com> wrote in message
news:29842C20-FF5A-42EB...@microsoft.com...

Scott McPhillips [MVP]

unread,
Dec 6, 2007, 9:36:15 AM12/6/07
to
"Jessica" <Jes...@discussions.microsoft.com> wrote in message
news:29842C20-FF5A-42EB...@microsoft.com...

MFC does most of it for you, in a better way. See
CPropertySheet::SetWizardMode

--
Scott McPhillips [VC++ MVP]

Tom Serface

unread,
Dec 6, 2007, 12:19:52 PM12/6/07
to
Here's an article to go with what Check and Scott replied:

http://www.dotnetheaven.com/Uploadfile/bulentozkir/pp_wizard04212005064904AM/pp_wizard.aspx?ArticleID=c9495c38-5107-4f20-b3c9-e561e4451775

Tom

"Jessica" <Jes...@discussions.microsoft.com> wrote in message
news:29842C20-FF5A-42EB...@microsoft.com...

Jessica

unread,
Dec 7, 2007, 12:12:01 AM12/7/07
to
Thank you very much, Check, Scott and Tom!
CPropertySheet!! This is what I was looking for!!

-Jessy

Jessica

unread,
Dec 7, 2007, 12:17:00 AM12/7/07
to
Hello Scott,

Can I create a dialog, implement a left pane which displays the steps of the
wizard with the currently active step highlighted, and then put the
ProperySheet in the main area of the dialog? Or can I only display the
Propertysheet standalone in a frame?

Thanks again,
Jessy

Jessica

unread,
Dec 7, 2007, 12:18:00 AM12/7/07
to
Hello Tom,

Can I create a dialog, implement a left pane which displays the steps of the
wizard with the currently active step highlighted, and then put the
ProperySheet in the main area of the dialog? Or can I only display the
Propertysheet standalone in a frame?

Thanks again,
Jessy

Tom Serface

unread,
Dec 7, 2007, 2:33:51 AM12/7/07
to
Maybe one of these ideas would work for you:

http://www.codeproject.com/KB/tabs/resizeable_wizard97.aspx

http://www.codeproject.com/KB/tabs/conquering_wizard97.aspx

The nice thing about the property sheet approach is that it really is just
like a bunch of dialogs that sequence. You can put all kinds of nice
graphics and text on each page to indicate where you are in the sequence.

Tom

"Jessica" <Jes...@discussions.microsoft.com> wrote in message

news:7B981D9B-9D75-491F...@microsoft.com...

Check Abdoul

unread,
Dec 7, 2007, 9:08:16 AM12/7/07
to
Take a look at the "FormSwap" article by Paul Dilascia (C++ Q&A) in

Dec '98 MSJ magazine.

Cheers
Check Abdoul
---------------------

"Jessica" <Jes...@discussions.microsoft.com> wrote in message

news:7B981D9B-9D75-491F...@microsoft.com...

David Ching

unread,
Dec 7, 2007, 10:06:33 AM12/7/07
to
"Jessica" <Jes...@discussions.microsoft.com> wrote in message
news:7B981D9B-9D75-491F...@microsoft.com...

> Hello Tom,
>
> Can I create a dialog, implement a left pane which displays the steps of
> the
> wizard with the currently active step highlighted, and then put the
> ProperySheet in the main area of the dialog? Or can I only display the
> Propertysheet standalone in a frame?
>

There isn't any way of putting a PropertySheet into another dialog,
unfortunately. If you want to keep using the PropertySheet (and it is the
easiest way of creating a wizard), then you could make each "interior page"
(all pages except the first and last ones) show an image on the left side of
the page. This is what the first and last pages have by default. And the
image you show on the interior pages would have the list of steps, with the
one for the current page highlighted. But this is harder to localize, since
all of the text in the steps is put into a graphic.

-- David


David Wilkinson

unread,
Dec 7, 2007, 10:24:42 AM12/7/07
to

David:

I've never done it, but I think you can put a modeless property sheet
inside a modal dialog (or anywhere).

--
David Wilkinson
Visual C++ MVP

Tom Serface

unread,
Dec 7, 2007, 10:32:39 AM12/7/07
to
This code uses propertypages as separate child dialogs, but it displays them
on a dialog with a tree control to move from page to page.

http://www.codeproject.com/KB/dialog/csettingsdlg.aspx

Tom


"David Wilkinson" <no-r...@effisols.com> wrote in message
news:ua%23rKVOO...@TK2MSFTNGP05.phx.gbl...

BobF

unread,
Dec 7, 2007, 11:11:13 AM12/7/07
to
I've also done this with tabbed pp and ps on a dialog-based app. It works
very well.
Here's the OnInitDialog that does it:

BOOL CVMRDialog::OnInitDialog()
{
CDialog::OnInitDialog();

// load the menu
m_menu.LoadMenu(IDR_MAINFRAME);
SetMenu(&m_menu);
m_menu.EnableMenuItem(ID_CHANNEL_CLOSE, MF_GRAYED);

OnChannelNew(); // adds the initial prop -page-

// create the property -sheet-
m_propsheet.Create(this, WS_CHILD|WS_VISIBLE);
m_propsheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

// tighten up the size of the main dialog box
// to fit neatly around the prop pages
CMainDlg* pp = (CMainDlg*)m_propsheet.GetActivePage();
RECT rect;

// no need to call ScreenToClient - we're only using
// values for relative sizing
pp->GetWindowRect(&rect);
// get the tab rect so the tab height can
// be accounted for
CTabCtrl* tcp = m_propsheet.GetTabControl();
RECT trect;
tcp->GetItemRect(0, &trect);
SetWindowPos(NULL,
0,0,rect.left+rect.right,rect.bottom+(trect.bottom-trect.top),
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);

return TRUE;
}


And OnChannelNew (a menu selection):

void CVMRDialog::OnChannelNew()
{
CMainDlg *pnewChannel;
pnewChannel = new CMainDlg(this);
if (pnewChannel != NULL)
{
m_chList.insert(m_chList.end(), pnewChannel);
m_chIter = m_chList.end();
m_propsheet.AddPage(pnewChannel);
m_propsheet.SetActivePage(pnewChannel);
if (m_chList.size() > 1)
m_menu.EnableMenuItem(ID_CHANNEL_CLOSE, MF_ENABLED);
}
else //pnewChannel != NULL
{
AfxMessageBox("New Port Create Failed");
}
}

"Tom Serface" <tom.n...@camaswood.com> wrote in message
news:6A68C4FB-1D85-4DBF...@microsoft.com...

David Ching

unread,
Dec 7, 2007, 11:50:02 AM12/7/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:%23YpfMvO...@TK2MSFTNGP03.phx.gbl...

Hey, neat! But does it look good? I'm not sure how the property sheet
header (the area at the top of each page which has the icon and boldface
subtitle) would look if that was spread across the property sheet child
wndow and not across the entire dialog?

Thanks,
David


BobF

unread,
Dec 7, 2007, 12:37:34 PM12/7/07
to
If you're interested, I'll post a screenshot somewhere layer today or
tomorrow.


"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:%Qe6j.3536$NY....@nlpi068.nbdc.sbc.com...

David Ching

unread,
Dec 7, 2007, 2:16:28 PM12/7/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:%23UhtcfP...@TK2MSFTNGP03.phx.gbl...

> If you're interested, I'll post a screenshot somewhere layer today or
> tomorrow.
>

Sure, it would be interesting to see. I think maybe your technique would be
better suited to non-Wizard 97 compliant wizards without the banner on top.

-- David


BobF

unread,
Dec 8, 2007, 9:52:03 AM12/8/07
to
David - This is what it looks like:

http://home.centurytel.net/bobf/mon.jpg

"David Ching" <d...@remove-this.dcsoft.com> wrote in message

news:i_g6j.3173$Vq....@nlpi061.nbdc.sbc.com...

David Ching

unread,
Dec 8, 2007, 1:10:46 PM12/8/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:%23ORsnna...@TK2MSFTNGP06.phx.gbl...

> David - This is what it looks like:
>
> http://home.centurytel.net/bobf/mon.jpg
>

Wow, this looks great. I wanted to do something similar recently but ended
up sticking with a normal CTabCtrl. How did you get rid of the buttons on
the bottom which normally appear in a CPropertySheet? Also, for the record,
this really isn't a wizard, it is a PropertySheet but not used in wizard
mode, it is the mode with the tabs across the top. So that's why there is
no white banner on top to worry about.

Cheers,
David


Tom Serface

unread,
Dec 8, 2007, 4:48:56 PM12/8/07
to
Hi Bob,

I think that looks great. Thanks for sharing. Did you do this with a tab
control rather than a property sheet?

Tom

"BobF" <rNfOrS...@charter.net> wrote in message

news:%23ORsnna...@TK2MSFTNGP06.phx.gbl...

BobF

unread,
Dec 9, 2007, 6:40:31 AM12/9/07
to

"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:G6B6j.23402$4V6....@newssvr14.news.prodigy.net...

I'm well aware of the fact that it's not a wizard. I was just demonstrating
that property sheets on dialogs is possible - to decent effect <g>

As far as the buttons go, since this wasn't created with a wizard wizard ...
I simply added a dialog through the resource editor and chose the prop page
type of dialog. This gives you the ability to make it what ever you want it
to be.

BobF

unread,
Dec 9, 2007, 6:59:26 AM12/9/07
to

"Tom Serface" <tom.n...@camaswood.com> wrote in message
news:F754540E-B6A1-42F4...@microsoft.com...

> Hi Bob,
>
> I think that looks great. Thanks for sharing. Did you do this with a tab
> control rather than a property sheet?
>
> Tom

CPropertySheet *is* a tabbed dialog:

<http://msdn2.microsoft.com/en-us/library/614xe086(VS.80).aspx>

David Ching

unread,
Dec 9, 2007, 10:33:12 AM12/9/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:%23sQlQhl...@TK2MSFTNGP06.phx.gbl...

>
> I'm well aware of the fact that it's not a wizard. I was just
> demonstrating that property sheets on dialogs is possible - to decent
> effect <g>
>
> As far as the buttons go, since this wasn't created with a wizard wizard
> ... I simply added a dialog through the resource editor and chose the prop
> page type of dialog. This gives you the ability to make it what ever you
> want it to be.
>

What? Does your code use CPropertySheet and CPropertyPage or not? You
can't add either in the resource editor!

Thanks,
David


BobF

unread,
Dec 9, 2007, 11:05:19 AM12/9/07
to

"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:YUT6j.69560$RX.1...@newssvr11.news.prodigy.net...

It uses obviously them both. The prop pages are -created- with the resource
editor and -added- programmatically during run-time.

David Ching

unread,
Dec 9, 2007, 11:09:54 AM12/9/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:uEndO1nO...@TK2MSFTNGP05.phx.gbl...

> It uses obviously them both. The prop pages are -created- with the
> resource editor and -added- programmatically during run-time.
>

What's throwing me off is the that in a normal CPropertySheet, there are
OK/Cancel/Apply buttons beneath the tabs. These don't appear in your screen
shot. How did you hide them?

Thanks,
David


BobF

unread,
Dec 9, 2007, 11:20:04 AM12/9/07
to

"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:mrU6j.28644$JD...@newssvr21.news.prodigy.net...

m_propsheet.Create(this, WS_CHILD|WS_VISIBLE);
m_propsheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

are the lines which create the sheet. By default, this creates a tabbed
dialog.

To get buttons instead of tabs would require calling SetWizardMode as shown
here:

<http://msdn2.microsoft.com/en-us/library/1sse9730(VS.80).aspx>


David Ching

unread,
Dec 9, 2007, 11:40:08 AM12/9/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:Ojm0d9nO...@TK2MSFTNGP06.phx.gbl...

>
> m_propsheet.Create(this, WS_CHILD|WS_VISIBLE);
> m_propsheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT);
>
> are the lines which create the sheet. By default, this creates a tabbed
> dialog.
>
> To get buttons instead of tabs would require calling SetWizardMode as
> shown here:
>
> <http://msdn2.microsoft.com/en-us/library/1sse9730(VS.80).aspx>
>

Look at http://www.microsoft.com/msj/0398/c0398.aspx and scroll down mid-way
to Figure 6. That's what my understanding of a CPropertySheet in non-wizard
mode looks like. It has the OK/Cancel/Apply buttons. Are you saying that
if you create the propertysheet with the WS_CHILD style, it doesn't have
those buttons? If so, that is major cool.

Thanks,
David


BobF

unread,
Dec 9, 2007, 11:51:06 AM12/9/07
to

"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:ITU6j.28652$JD.1...@newssvr21.news.prodigy.net...

:-)) I've shown you everything I did with the prop sheet,
so I guess it *is* 'Major Kool', although I'm not sure it is the
WS_CHILD style that does the trick. If I understand it correctly,
not setting wizard mode is what does the trick.

David Wilkinson

unread,
Dec 9, 2007, 12:51:20 PM12/9/07
to
David Ching wrote:

> Look at http://www.microsoft.com/msj/0398/c0398.aspx and scroll down mid-way
> to Figure 6. That's what my understanding of a CPropertySheet in non-wizard
> mode looks like. It has the OK/Cancel/Apply buttons. Are you saying that
> if you create the propertysheet with the WS_CHILD style, it doesn't have
> those buttons? If so, that is major cool.

David:

If you look in "The MFC Answer Book" by Eugene Kain (which is easy for
me because I have a copy sitting on my lap...) there is a whole section
on embedding (non-Wizard) property sheets in a dialog. The example
illustrations do not show the standard property sheet buttons, and I do
not see anything in the example code that removes them.

BobF

unread,
Dec 9, 2007, 1:07:56 PM12/9/07
to

"David Wilkinson" <no-r...@effisols.com> wrote in message
news:uhHkawoO...@TK2MSFTNGP03.phx.gbl...

That's because they are tabbed by default. You either get tabs or buttons
:-)


David Ching

unread,
Dec 9, 2007, 3:00:36 PM12/9/07
to
"David Wilkinson" <no-r...@effisols.com> wrote in message
news:uhHkawoO...@TK2MSFTNGP03.phx.gbl...

> David:
>
> If you look in "The MFC Answer Book" by Eugene Kain (which is easy for me
> because I have a copy sitting on my lap...) there is a whole section on
> embedding (non-Wizard) property sheets in a dialog. The example
> illustrations do not show the standard property sheet buttons, and I do
> not see anything in the example code that removes them.
>

Thanks David, I will definitely need to revisit my app and most probably
replace the CTabCtrl with a CPropertySheet then!

-- David


David Ching

unread,
Dec 9, 2007, 3:00:01 PM12/9/07
to
"BobF" <rNfOrS...@charter.net> wrote in message
news:uOjov5oO...@TK2MSFTNGP02.phx.gbl...

>
> That's because they are tabbed by default. You either get tabs or buttons
> :-)

No Bob, with the tabs you get OK/Cancel/Apply buttons, and with Wizard you
get Back/Next/Cancel/Finish buttons. Either mode you get buttons!

-- David


BobF

unread,
Dec 9, 2007, 4:02:22 PM12/9/07
to

"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:5PX6j.76901$YL5....@newssvr29.news.prodigy.net...

Then why doesn't mine have buttons? I did nothing to make them go away


0 new messages