Partager via


CMultiPageDHtmlDialog Class

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

class CMultiPageDHtmlDialog : public CDHtmlDialog

Members

Public Constructors

Name

Description

CMultiPageDHtmlDialog::CMultiPageDHtmlDialog

Constructs a multipage (wizard-style) DHTML dialog object.

CMultiPageDHtmlDialog::~CMultiPageDHtmlDialog

Destroys a multipage DHTML dialog object.

Remarks

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

Example

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()

   // rest of class declaration omitted

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("153"), Page1)
      URL_EVENT_ENTRY(CMyMultiPageDlg, _T("154"), Page2)
      URL_EVENT_ENTRY(CMyMultiPageDlg, _T("155"), Page3)
      // Note: IDR_PAGE1 = 153, IDR_PAGE2 = 154, IDR_PAGE3 = 155
   END_URL_ENTRIES()

END_DHTML_URL_EVENT_MAP(CMyMultiPageDlg)

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

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

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

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

Inheritance Hierarchy

CObject

CDHtmlSinkHandlerBase2

CDHtmlSinkHandlerBase1

CCmdTarget

CDHtmlSinkHandler

CWnd

CDHtmlEventSink

CDialog

CDHtmlDialog

CMultiPageDHtmlDialog

Requirements

Header: afxdhtml.h

See Also

Reference

CDHtmlDialog Class

Other Resources

Multipage DHTML and URL Event Maps