Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CMultiPageDHtmlDialog Class 

A multipage dialog displays multiple HTML pages sequentially and handles the events from each page.


class CMultiPageDHtmlDialog : public CDHtmlDialog

The mechanism for doing this is a DHTML and URL event map, which contains embedded event maps for each page.

This multipage dialog assumes three HTML resources that define simple wizard-like functionality. The first page has a Next button, the second a Prev and Next button, and the third a Prev button. When one of the buttons is pressed, a handler function calls CDHtmlDialog::LoadFromResource to load the appropriate new page.

The pertinent parts of the class declaration (in CMyMultiPageDlg.h):

class CMyMultiPageDlg : public CMultiPageDHtmlDialog
{
public:
   // Declare the DHTML event handlers:
   HRESULT OnPage1Next(IHTMLElement *pElement);
   HRESULT OnPage2Next(IHTMLElement *pElement);
   HRESULT OnPage2Back(IHTMLElement *pElement);
   HRESULT OnPage3Back(IHTMLElement *pElement);
...
   DECLARE_DHTML_URL_EVENT_MAP()
}

The pertinent parts of the class implementation (in CMyMultipageDlg.cpp):

BEGIN_DHTML_URL_EVENT_MAP(CMyMultiPageDlg)

   BEGIN_EMBED_DHTML_EVENT_MAP(CMyMultiPageDlg, Page1)
      DHTML_EVENT_ONCLICK(_T("Next"), OnPage1Next)
   END_EMBED_DHTML_EVENT_MAP()

   BEGIN_EMBED_DHTML_EVENT_MAP(CMyMultiPageDlg, Page2)
      DHTML_EVENT_ONCLICK(_T("Back"), OnPage2Back)
      DHTML_EVENT_ONCLICK(_T("Next"), OnPage2Next)
   END_EMBED_DHTML_EVENT_MAP()

   BEGIN_EMBED_DHTML_EVENT_MAP(CMyMultiPageDlg, Page3)
      DHTML_EVENT_ONCLICK(_T("Back"), OnPage3Back)
   END_EMBED_DHTML_EVENT_MAP()

   BEGIN_URL_ENTRIES(CMyMultiPageDlg)
      URL_EVENT_ENTRY(CMyMultiPageDlg, _T("131"), Page1)
      URL_EVENT_ENTRY(CMyMultiPageDlg, _T("132"), Page2)
      URL_EVENT_ENTRY(CMyMultiPageDlg, _T("133"), Page3)
      // Note: IDR_PAGE1 = 131, IDR_PAGE2 = 132, IDR_PAGE3 = 133
   END_URL_ENTRIES()

END_DHTML_URL_EVENT_MAP(CMyMultiPageDlg)

HRESULT CMyMultiPageDlg::OnPage1Next(IHTMLElement *pElement)
{
   LoadFromResource(IDR_PAGE2);
   return S_OK;
}

HRESULT CMyMultiPageDlg::OnPage2Next(IHTMLElement *pElement)
{
   LoadFromResource(IDR_PAGE3);
   return S_OK;
}

HRESULT CMyMultiPageDlg::OnPage2Back(IHTMLElement *pElement)
{
   LoadFromResource(IDR_PAGE1);
   return S_OK;
}

HRESULT CMyMultiPageDlg::OnPage3Back(IHTMLElement *pElement)
{
   LoadFromResource(IDR_PAGE2);
   return S_OK;
}

Header: afxdhtml.h

This class is not supported in Smart Device projects.

Community Additions

ADD
Show:
© 2015 Microsoft