www.pudn.com > WordReadWritebyVC.rar > DlgProxy.cpp


// DlgProxy.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "WordAutomation.h" 
#include "DlgProxy.h" 
#include "WordAutomationDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CWordAutomationDlgAutoProxy 
 
IMPLEMENT_DYNCREATE(CWordAutomationDlgAutoProxy, CCmdTarget) 
 
CWordAutomationDlgAutoProxy::CWordAutomationDlgAutoProxy() 
{ 
	EnableAutomation(); 
	 
	// To keep the application running as long as an automation  
	//	object is active, the constructor calls AfxOleLockApp. 
	AfxOleLockApp(); 
 
	// Get access to the dialog through the application's 
	//  main window pointer.  Set the proxy's internal pointer 
	//  to point to the dialog, and set the dialog's back pointer to 
	//  this proxy. 
	ASSERT (AfxGetApp()->m_pMainWnd != NULL); 
	ASSERT_VALID (AfxGetApp()->m_pMainWnd); 
	ASSERT_KINDOF(CWordAutomationDlg, AfxGetApp()->m_pMainWnd); 
	m_pDialog = (CWordAutomationDlg*) AfxGetApp()->m_pMainWnd; 
	m_pDialog->m_pAutoProxy = this; 
} 
 
CWordAutomationDlgAutoProxy::~CWordAutomationDlgAutoProxy() 
{ 
	// To terminate the application when all objects created with 
	// 	with automation, the destructor calls AfxOleUnlockApp. 
	//  Among other things, this will destroy the main dialog 
	if (m_pDialog != NULL) 
		m_pDialog->m_pAutoProxy = NULL; 
	AfxOleUnlockApp(); 
} 
 
void CWordAutomationDlgAutoProxy::OnFinalRelease() 
{ 
	// When the last reference for an automation object is released 
	// OnFinalRelease is called.  The base class will automatically 
	// deletes the object.  Add additional cleanup required for your 
	// object before calling the base class. 
 
	CCmdTarget::OnFinalRelease(); 
} 
 
BEGIN_MESSAGE_MAP(CWordAutomationDlgAutoProxy, CCmdTarget) 
	//{{AFX_MSG_MAP(CWordAutomationDlgAutoProxy) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
BEGIN_DISPATCH_MAP(CWordAutomationDlgAutoProxy, CCmdTarget) 
	//{{AFX_DISPATCH_MAP(CWordAutomationDlgAutoProxy) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_DISPATCH_MAP 
END_DISPATCH_MAP() 
 
// Note: we add support for IID_IWordAutomation to support typesafe binding 
//  from VBA.  This IID must match the GUID that is attached to the  
//  dispinterface in the .ODL file. 
 
// {0CBEEE24-BEBF-11D8-82B9-0001028D890C} 
static const IID IID_IWordAutomation = 
{ 0xcbeee24, 0xbebf, 0x11d8, { 0x82, 0xb9, 0x0, 0x1, 0x2, 0x8d, 0x89, 0xc } }; 
 
BEGIN_INTERFACE_MAP(CWordAutomationDlgAutoProxy, CCmdTarget) 
	INTERFACE_PART(CWordAutomationDlgAutoProxy, IID_IWordAutomation, Dispatch) 
END_INTERFACE_MAP() 
 
// The IMPLEMENT_OLECREATE2 macro is defined in StdAfx.h of this project 
// {0CBEEE22-BEBF-11D8-82B9-0001028D890C} 
IMPLEMENT_OLECREATE2(CWordAutomationDlgAutoProxy, "WordAutomation.Application", 0xcbeee22, 0xbebf, 0x11d8, 0x82, 0xb9, 0x0, 0x1, 0x2, 0x8d, 0x89, 0xc) 
 
///////////////////////////////////////////////////////////////////////////// 
// CWordAutomationDlgAutoProxy message handlers