GME  13
ScriptHost.h
Go to the documentation of this file.
00001 // ScriptHost.h : Declaration of the CScriptHost
00002 
00003 #ifndef __SCRIPTHOST_H_
00004 #define __SCRIPTHOST_H_
00005 
00006 #include "resource.h"       // main symbols
00007 #include "ActivScp.h"
00008 #include "gme.h"
00009 
00010 #include <comdef.h>
00011 #include "comdefsp.h"
00012 
00013 _COM_SMARTPTR_TYPEDEF(IActiveScript, __uuidof(IActiveScript));
00014 _COM_SMARTPTR_TYPEDEF(IActiveScriptParse, __uuidof(IActiveScriptParse));
00015 _COM_SMARTPTR_TYPEDEF(IActiveScriptSite, __uuidof(IActiveScriptSite));
00016 _COM_SMARTPTR_TYPEDEF(IActiveScriptError, __uuidof(IActiveScriptError));
00017 
00018 
00019 class CConsoleCtrl;
00021 // CScriptHost
00022 class ATL_NO_VTABLE CScriptHost : 
00023         public CComObjectRootEx<CComSingleThreadModel>,
00024         public CComCoClass<CScriptHost, &CLSID_ScriptHost>,
00025         public IDispatchImpl<IScriptHost, &IID_IScriptHost, &LIBID_CONSOLELib>,
00026         public IActiveScriptSite
00027 {
00028 public:
00029         CScriptHost()
00030                 : m_console(0)
00031                 , m_iscript(0)
00032                 , m_iscriptParse(0)
00033                 , m_enginePID("")
00034         {
00035         }
00036         virtual ~CScriptHost()
00037         {
00038         }
00039 
00040 DECLARE_REGISTRY_RESOURCEID(IDR_SCRIPTHOST)
00041 
00042 DECLARE_PROTECT_FINAL_CONSTRUCT()
00043 
00044 BEGIN_COM_MAP(CScriptHost)
00045         COM_INTERFACE_ENTRY(IScriptHost)
00046         COM_INTERFACE_ENTRY(IDispatch)
00047         COM_INTERFACE_ENTRY(IActiveScriptSite)
00048 END_COM_MAP()
00049 
00050 // IScriptHost
00051 public:
00052         STDMETHOD(ProcessString)(/*[in]*/ BSTR input);
00053         STDMETHOD(InitEngine)(/*[in]*/ IDispatch* console, /*[in]*/ BSTR engineProgid);
00054 
00055 // IActiveScriptSite
00056  public:
00057         STDMETHOD(SetGMEApp)(/*[in]*/ IDispatch* gmeapp);
00058         STDMETHOD(SetGMEProj)(/*[in]*/ IDispatch* gmeproj);
00059         STDMETHOD(GetLCID)(/*[out]*/ LCID *plcid);
00060         STDMETHOD(GetItemInfo)(
00061                 /*[in]*/  LPCOLESTR pstrName,
00062                 /*[in]*/  DWORD     dwReturnMask,
00063                 /*[out]*/ IUnknown  **ppiunkItem,
00064                 /*[out]*/ ITypeInfo **ppti);
00065         STDMETHOD(GetDocVersionString)(/*[out]*/ BSTR      *pbstrVersion);
00066         STDMETHOD(OnScriptTerminate)(
00067                 /*[in]*/  const VARIANT     *pvarResult,
00068                 /*[in]*/  const EXCEPINFO   *pexcepinfo);
00069         STDMETHOD(OnStateChange)(
00070                 /*[in]*/  SCRIPTSTATE       ssScriptState);
00071         STDMETHOD(OnScriptError)(
00072                 /*[in]*/  IActiveScriptError *pscripterror);
00073         STDMETHOD(OnEnterScript)(void);
00074         STDMETHOD(OnLeaveScript)(void);
00075 
00076 private:
00077         IDispatchPtr m_console;
00078         IActiveScriptPtr m_iscript;
00079         IActiveScriptParsePtr m_iscriptParse;
00080         _bstr_t m_enginePID;
00081 
00082         CComPtr<IGMEOLEApp>  m_gmeptr;
00083         CComPtr<IMgaProject> m_mgaproj;
00084         CComPtr<IGMEOLEIt>   m_actMod;
00085 
00086         void Message(BSTR message, msgtype_enum level);
00087 };
00088 
00089 #endif //__SCRIPTHOST_H_