XMLCustomizablePages.h
上传用户:kj0090
上传日期:2007-03-02
资源大小:39k
文件大小:4k
源码类别:
xml/soap/webservice
开发平台:
C/C++
- /***********************************************************************
- *
- * This module is part of the XMLGUI system
- *
- * File name: XMLCustomizablePages.h
- *
- * Creation date: [21 AUGUST 2002]
- *
- * Author(s): [Kolosenko Ruslan]
- *
- * Description: Declares class CXMLCustomizablePage - template class
- * for various kinds of customizable property pages
- *
- **********************************************************************/
- #ifndef AFX_XML_CUSTOMIZABLE_PAGES_H_RKOL_8_21_2002_
- #define AFX_XML_CUSTOMIZABLE_PAGES_H_RKOL_8_21_2002_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "DlgTemplate.h"
- #include "xmlgui_resource.h"
- // exported global function declaration, implemented in XMLCustomizable.cpp
- void XMLGUI_EXT_CLASS CXMLCustomizable_CustomizeXML(LPCTSTR szXMLFile);
- template <class PageClass> class CXMLCustomizablePage : public PageClass
- {
- public:
- // one version of constructor accepts resource ID as a reserve
- // for form creation if the XML file is not valid
- CXMLCustomizablePage(LPCTSTR szXMLFile, UINT nIDTemplate = 0, UINT nIDCaption = 0)
- : PageClass(nIDTemplate, nIDCaption)
- {
- m_szXMLFile = szXMLFile; // store the name of the XML file
- // try to read dialog template from the specified XML file
- if ( !m_szXMLFile.IsEmpty() && m_Template.SerializeFrom(m_szXMLFile) )
- {
- // if XML is read successfully - initialize the property page
- // with the obtained dialog template
- m_psp.dwFlags |= PSP_DLGINDIRECT;
- m_psp.pResource = (LPDLGTEMPLATE)m_Template;
- m_lpDialogInit = m_Template.GetInitData();
- }
- }
- // another version of constructor accepts resource name as a reserve
- // for dialog creation if the XML file is not valid
- CXMLCustomizablePage(LPCTSTR szXMLFile, LPCTSTR szTemplateName, UINT nIDCaption = 0)
- : PageClass(szTemplateName, nIDCaption)
- {
- m_szXMLFile = szXMLFile;
- // try to read dialog template from the specified XML file
- if ( !m_szXMLFile.IsEmpty() && m_Template.SerializeFrom(m_szXMLFile) )
- {
- // if XML is valid - initialize the property page from XML
- m_psp.dwFlags |= PSP_DLGINDIRECT;
- m_psp.pResource = (LPDLGTEMPLATE)m_Template;
- m_lpDialogInit = m_Template.GetInitData();
- }
- }
- protected:
- // Windows messages handler for the dialog
- virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
- {
- if ( message == WM_CONTEXTMENU )
- {
- // show context menu with "Customize" option
- CMenu menu;
- menu.LoadMenu(IDR_XMLGUI_CUSTOMIZING);
- CMenu* pPopup = menu.GetSubMenu(0);
- pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,MAKEPOINTS(lParam).x,
- MAKEPOINTS(lParam).y,this);
- }
- if ( message == WM_COMMAND && wParam == ID_XMLGUI_CUSTOMIZE )
- {
- // handle "Customize" command from the popup menu
- // global function CXMLCustomizable_CustomizeXML does this
- CXMLCustomizable_CustomizeXML(m_szXMLFile);
- }
- // pass the message to the base class dialog box procedure
- return PageClass::OnWndMsg(message,wParam,lParam,pResult);
- }
- CDlgTemplate m_Template; // dialog template object holding the Win32 DLGTEMPLATE
- CString m_szXMLFile; // full name of the file with XML-style dialog template
- };
- // instantiation of CXMLCustomizablePage for MFC class CPropertyPage
- typedef CXMLCustomizablePage<CPropertyPage> CXMLGUIPropertyPage;
- #endif // AFX_XML_CUSTOMIZABLE_PAGES_H_RKOL_8_21_2002_