Click here to Skip to main content
15,895,142 members
Articles / Desktop Programming / MFC

Embeddable script editor for MFC applications

Rate me:
Please Sign up or sign in to vote.
4.90/5 (60 votes)
15 Jul 20032 min read 336.9K   6.4K   130  
A library that allows you to embed scripting functionality to your C++ MFC application.
// CmdTargetPlus.h : header file
//

#ifndef __CMDTARGETPLUS_H__
#define __CMDTARGETPLUS_H__
#include <activscp.h> // Active Scripting Interfaces
#include <afxctl.h>			// For Event Map things
/////////////////////////////////////////////////////////////////////////////
// CCmdTargetPlus command target

class  CCmdTargetPlus : public CCmdTarget
{
	DECLARE_DYNCREATE(CCmdTargetPlus)

public:
	CCmdTargetPlus();           // protected constructor used by dynamic creation
	virtual ~CCmdTargetPlus();

// Attributes
public:

// Operations
public:
	void AFX_CDECL FireEvent(DISPID dispid, BYTE* pbParams, ...);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCmdTargetPlus)
	public:
	virtual void OnFinalRelease();
	//}}AFX_VIRTUAL

// Implementation
protected: 

	// Events
	static const AFX_DATA AFX_EVENTMAP_ENTRY _eventEntries[];
	virtual const AFX_EVENTMAP* GetEventMap() const;
	static const AFX_DATA AFX_EVENTMAP eventMap;
	const AFX_EVENTMAP_ENTRY* GetEventMapEntry(LPCTSTR pszName,
		DISPID* pDispid) const;
	void FireEventV(DISPID dispid, BYTE* pbParams, va_list argList);

	// Generated message map functions
	//{{AFX_MSG(CCmdTargetPlus)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
	// Generated OLE dispatch map functions
	//{{AFX_DISPATCH(CCmdTargetPlus)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()

	// Connection point container
	virtual LPCONNECTIONPOINT GetConnectionHook(REFIID iid);
	virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints);

	// Connection point for events - from COleControl
	BEGIN_CONNECTION_PART(CCmdTargetPlus, EventConnPt)
		virtual void OnAdvise(BOOL bAdvise);
		virtual REFIID GetIID();
		virtual LPUNKNOWN QuerySinkInterface(LPUNKNOWN pUnkSink);
	END_CONNECTION_PART(EventConnPt)

	// IProvideClassInfo2
	BEGIN_INTERFACE_PART(ProvideClassInfo, IProvideClassInfo2)
		INIT_INTERFACE_PART(COleControl, ProvideClassInfo)
		STDMETHOD(GetClassInfo)(LPTYPEINFO* ppTypeInfo);
		STDMETHOD(GetGUID)(DWORD dwGuidKind, GUID* pGUID);
	END_INTERFACE_PART(ProvideClassInfo)

public:
	virtual HRESULT GetClassID(LPCLSID pclsid);

	BOOL GetDispatchIID(IID* pIID);

	const IID* m_piidEvents;            // IID for control events
	const IID* m_piidPrimary;			  // IID for primary idispatch
};

/////////////////////////////////////////////////////////////////////////////

#endif // __CMDTARGETPLUS_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) RDV Systems
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions