Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / MFC

Develop MFC Doc/View Application Which Supports Any Number Document Template

Rate me:
Please Sign up or sign in to vote.
1.57/5 (3 votes)
2 Jun 20052 min read 36.4K   1.7K   26  
This article provides an introduction to TangramLittle, a C++ Framework for MFC and the .NET Framework. Knowledge in MFC and the .NET Framework is assumed.
#pragma once
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Windows::Forms;

class CUserCtrlView : public CView
{
	DECLARE_DYNCREATE(CUserCtrlView)
protected:
	CUserCtrlView();           // protected constructor used by dynamic creation
	virtual ~CUserCtrlView();

	CString m_strWinCtrlID;
	BOOL	m_bDotNetView;
public:
    gcroot< Object* >	m_pWinFormControl;

	class  CWFControlWrapper : public CWnd
	{
		public:
			CWFControlWrapper();
			virtual ~CWFControlWrapper(void); 

			IUnknown * pUnkControl ;
			IUnknown * GetManagedControl() { return pUnkControl; }
			void  SetControlSite(COleControlSite * pSite) { m_pCtrlSite = pSite; }
	};

	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif
protected:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
	virtual void OnInitialUpdate();
protected:
	afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	DECLARE_MESSAGE_MAP()
private:
	CWFControlWrapper m_Control;
	virtual BOOL CreateControlSite( COleControlContainer*, COleControlSite** ppSite, UINT nID, REFCLSID clsid );
public:
	IUnknown * GetUnk() { return m_Control.pUnkControl; }
	IDispatch* GetDispatch();
};

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



Comments and Discussions