XMLCustomizable.cpp
上传用户:kj0090
上传日期:2007-03-02
资源大小:39k
文件大小:4k
源码类别:
xml/soap/webservice
开发平台:
C/C++
- /***********************************************************************
- *
- * This module is part of the XMLGUI system
- *
- * File name: XMLCustomizable.cpp
- *
- * Creation date: [21 AUGUST 2002]
- *
- * Author(s): [Kolosenko Ruslan]
- *
- * Description: Implements some global routines common to CXMLCustomizable
- * template classes
- *
- **********************************************************************/
- #include "stdafx.h"
- #include "XMLCustomizableForms.h"
- // include from Program FilesMicrosoft Visual StudioVC98MFCSRC
- #include "..srcoccimpl.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- /**************************************************************************
- * Function : CXMLCustomizable_CustomizeXML
- * Description : Invoked when user chooses "Customize" from the dialog's
- * : popup menu. Starts redactor for the XMLGUI dialog template
- * Arguments : szXMLFile - pointer to a string with the name of XML file
- * : containing XML-style template for dialog
- ***************************************************************************/
- void XMLGUI_EXT_CLASS CXMLCustomizable_CustomizeXML(LPCTSTR szXMLFile)
- {
- // build command line for the redactor application
- CString szCommandLine = " ";
- szCommandLine += szXMLFile;
- int nCommandLineLength = szCommandLine.GetLength();
- // startup info for the redactor's process is taken similar to that
- // of invoking application
- STARTUPINFO startUpInfo;
- PROCESS_INFORMATION processInfo;
- ::GetStartupInfo(&startUpInfo);
- // retrieve %WINDIR% variable value to build path to the notepad.exe
- CString szWinDir;
- DWORD nWinDirLength = ::GetEnvironmentVariable(_T("windir"),szWinDir.GetBuffer(0),0);
- szWinDir.ReleaseBuffer();
- ::GetEnvironmentVariable(_T("windir"),szWinDir.GetBuffer(nWinDirLength),nWinDirLength);
- szWinDir.ReleaseBuffer();
- // start notepad.exe with the XML file name as the command line parameter
- ::CreateProcess(szWinDir+"\notepad.exe",szCommandLine.GetBuffer(nCommandLineLength),
- NULL,NULL,FALSE,0,NULL,NULL,&startUpInfo,&processInfo);
- szCommandLine.ReleaseBuffer();
- }
- #ifndef _AFX_NO_OCC_SUPPORT
- /**************************************************************************
- * Function : CXMLCustomizable_InitializeForm
- * Description : Invoked from the WM_INITDIALOG handler of CFormView-derived
- * : classes, initializes OLE controls on the form view
- * Arguments : pFormView - pointer to the form view being initialized
- * : pOccDialogInfo - pointer to the OCC dialog info, the form
- * : should pass its protected member m_pOccDialogInfo
- * : pDlgTemplate - pointer to the CDlgTemplate object, holding
- * : init data for the created OLE controls
- * : szTemplateName - pointer to a string holding the name
- * : of the dialog template resource for the view, used as
- * : a reserve if init data cannot be obtained from CDlgTemplate
- ***************************************************************************/
- void XMLGUI_EXT_CLASS CXMLCustomizable_InitializeForm(CFormView* pFormView,
- _AFX_OCC_DIALOG_INFO* pOccDialogInfo,CDlgTemplate* pDlgTemplate,
- LPCTSTR szTemplateName)
- {
- // create OLE controls
- COccManager* pOccManager = afxOccManager;
- if ((pOccManager != NULL) && (pOccDialogInfo != NULL))
- {
- if ( (LPDLGTEMPLATE)(*pDlgTemplate) )
- {
- // if dialog template is valid DLGTEMPLATE -
- // we can obtain init data from it
- pOccManager->CreateDlgControls(pFormView,pDlgTemplate->GetInitData(),
- pOccDialogInfo);
- }
- else
- {
- // otherwise we use init data from resources
- pOccManager->CreateDlgControls(pFormView,szTemplateName,
- pOccDialogInfo);
- }
- }
- }
- #endif /* _AFX_NO_OCC_SUPPORT */