- /***********************************************************************
- *
- * This module is part of the XMLGUI system
- *
- * File name: DlgTemplate.h
- *
- * Creation date: [12 AUGUST 2002]
- *
- * Author(s): [Kolosenko Ruslan]
- *
- * Description: Declares the CDlgTemplate class
- *
- **********************************************************************/
- #ifndef AFX_DLGTEMPLATE_H_RKOL_8_12_2002_
- #define AFX_DLGTEMPLATE_H_RKOL_8_12_2002_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "XMLGUIMacro.h"
- #include "DlgItemTemplate.h"
- #include <afxtempl.h>
- // array of item templates for dialog's controls
- typedef CArray<CDlgItemTemplate,CDlgItemTemplate&> DLGITEMSARRAY;
- class XMLGUI_EXT_CLASS CDlgTemplate
- {
- public:
- CDlgTemplate();
- virtual ~CDlgTemplate();
- // dialog's data ( public access )
- DWORD style; // style of the dialog window
- DWORD dwExtendedStyle; // ex.style of the dialog window
- // all sizes below are in dialog units
- short x; // left border of the dialog window
- short y; // top border of the dialog window
- short cx; // width of the dialog window
- short cy; // height of the dialog window
- // the next field is taken into consideration only if dialog has DS_SETFONT style
- WORD m_nFontSize; // point size of the font used on the dialog
- DLGITEMSARRAY controls; // array of dialog's controls
- protected:
- // dialog's data ( protected access )
- _bstr_t m_strTitle; // title of the dialog window
- // the next field is taken into consideration only if dialog has DS_SETFONT style
- _bstr_t m_strFontTypeface; // typeface name of the font used on the dialog
- _bstr_t m_strMenuName; // menu for the dialog can be specified either by string
- WORD m_nMenuID; // containing menu name or by number containing
- // menu identifier in the resource file
- _bstr_t m_strWndClass; // window class for the dialog can be specified either
- WORD m_nWndClassOrdinal; // by name or by ordinal number as well
- HGLOBAL m_hGlobalTemplate; // handle to the allocated global memory
- // holding Win32 DLGTEMPLATE structure
- LPVOID m_pInitData; // pointer to the allocated memory with init data
- public:
- // retrieving and setting protected dialog's data members
- WORD cdit() // get number of controls
- { return (WORD)controls.GetSize(); }
- CString GetTitle() // get dialog's caption
- { return (LPCTSTR)m_strTitle; }
- void SetTitle(LPCTSTR szTitle) // set dialog's caption
- { m_strTitle = szTitle; }
- void SetTitle(const _bstr_t& strTitle)
- { m_strTitle = strTitle; }
- CString GetFontTypeface() // get name of the dialog's font
- { return (LPCTSTR)m_strFontTypeface; }
- void SetFontTypeface(LPCTSTR szFontTypeface) // set name of the font
- { m_strFontTypeface = szFontTypeface; }
- void SetFontTypeface(const _bstr_t& strFontTypeface)
- { m_strFontTypeface = strFontTypeface; }
- CString GetMenuName() // get menu name
- { return (LPCTSTR)m_strMenuName; }
- void SetMenuName(LPCTSTR szName) // set menu name
- { m_strMenuName = szName; m_nMenuID = 0; }
- void SetMenuName(const _bstr_t& strName)
- { m_strMenuName = strName; m_nMenuID = 0; }
- WORD GetMenuID() // get menu identifier
- { return m_nMenuID; }
- void SetMenuID(WORD nID) // set menu identifier
- { m_nMenuID = nID; m_strMenuName = _T(""); }
- CString GetWndClass() // get dialog window class
- { return (LPCTSTR)m_strWndClass; }
- void SetWndClass(LPCTSTR szClass) // set dialog window class
- { m_strWndClass = szClass; m_nWndClassOrdinal = 0; }
- void SetWndClass(const _bstr_t& strClass)
- { m_strWndClass = strClass; m_nWndClassOrdinal = 0; }
- WORD GetWndClassOrdinal() // get dialog window class ordinal
- { return m_nWndClassOrdinal; }
- void SetWndClassOrdinal(WORD nID) // set dialog window class ordinal
- { m_nWndClassOrdinal = nID; m_strWndClass = _T(""); }
- // general dlgtemplate's operations with public access
- BOOL SerializeFrom(LPCTSTR szXMLFile); // create dialog template from a file
- // with GUI template in XML
- BOOL SerializeFrom(IXMLElement* pXMLTag); // create dialog template given
- // a pointer to XML element
- CDlgTemplate& operator += (CDlgItemTemplate& newControl) // add a control to dialog
- { controls.SetAtGrow(cdit(),newControl); return *this; }
- operator LPDLGTEMPLATE(); // create and return Win32 DLGTEMPLATE structure
- UINT Length(); // return length in bytes of the resulting DLGTEMPLATE structure
- LPVOID GetInitData(); // create and return init data section for dialog controls
- UINT InitDataLength(); // return length in bytes of the dialog init data section
- void Invalidate(); // invalidate previously built DLGTEMPLATE structure,
- // free the allocated memory
- };
- #endif // AFX_DLGTEMPLATE_H_RKOL_8_12_2002_