Click here to Skip to main content
15,884,425 members
Articles / Desktop Programming / MFC

How to use Dynamic External MFC CView Class Objects (which exists in a DLL library) in a VBA Host MFC Application

Rate me:
Please Sign up or sign in to vote.
1.00/5 (10 votes)
8 Dec 20023 min read 57.2K   389   11  
Implement interface between two existing DLL Library in a VBA Host MFC application.
// ToolWndForm.cpp : implementation file
//

#include "stdafx.h"
#include "TangramMFC.h"
#include "ToolWndForm.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CToolWndForm

IMPLEMENT_DYNCREATE(CToolWndForm, CFormView)

CToolWndForm::CToolWndForm()
	: CFormView(CToolWndForm::IDD)
	, m_strCaption(_T(""))
	, m_strDesignerID(_T(""))
{
	//{{AFX_DATA_INIT(CToolWndForm)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CToolWndForm::~CToolWndForm()
{
}

void CToolWndForm::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CToolWndForm)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
	DDX_Text(pDX, IDC_EDIT_CAPTION, m_strCaption);
	DDX_Text(pDX, IDC_EDIT1, m_strDesignerID);
}


BEGIN_MESSAGE_MAP(CToolWndForm, CFormView)
	//{{AFX_MSG_MAP(CToolWndForm)
	ON_WM_DESTROY()
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON_CTRLBAR, OnBnClickedButtonCtrlbar)
	ON_BN_CLICKED(IDC_BUTTON_INSERTDESIGNER, OnBnClickedButtonInsertdesigner)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolWndForm diagnostics

#ifdef _DEBUG
void CToolWndForm::AssertValid() const
{
	CFormView::AssertValid();
}

void CToolWndForm::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CToolWndForm message handlers

void CToolWndForm::OnDestroy() 
{
	g_pTangramServer->ProcessDlgMsg(false,m_hWnd);
	CFormView::OnDestroy();
}
void CToolWndForm::OnBnClickedButtonCtrlbar()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	UpdateData(TRUE);
	m_strCaption.Trim();
	if(m_strCaption.GetLength()>0)
		((CMainFrame*)theApp.m_pMainWnd)->m_pDoc->CreateDockingBar(m_strCaption);
}

void CToolWndForm::OnBnClickedButtonInsertdesigner()
{
	// TODO: �ڴ���ӿؼ�֪ͨ����������
	UpdateData(TRUE);
	m_strDesignerID.Trim();
	if(m_strDesignerID.GetLength()>0)
	{
		GetClsIDString(m_strDesignerID);
		HRESULT hr = theApp.ApcHost->APC_RAW(SupportDesigner)(m_strDesignerID.AllocSysString(), VARIANT_TRUE);
		ASSERT(SUCCEEDED(hr));
		m_strDesignerID = _T("");
		UpdateData(false);
	}
}

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
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions