dlgproxy.cpp

来自「Visual C++高级编程及其项目应用开发(含源代码)」· C++ 代码 · 共 89 行

CPP
89
字号
// DlgProxy.cpp : implementation file
//

#include "stdafx.h"
#include "MyCommandTry.h"
#include "DlgProxy.h"
#include "MyCommandTryDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyCommandTryDlgAutoProxy

IMPLEMENT_DYNCREATE(CMyCommandTryDlgAutoProxy, CCmdTarget)

CMyCommandTryDlgAutoProxy::CMyCommandTryDlgAutoProxy()
{
	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(CMyCommandTryDlg, AfxGetApp()->m_pMainWnd);
	m_pDialog = (CMyCommandTryDlg*) AfxGetApp()->m_pMainWnd;
	m_pDialog->m_pAutoProxy = this;
}

CMyCommandTryDlgAutoProxy::~CMyCommandTryDlgAutoProxy()
{
	// 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 CMyCommandTryDlgAutoProxy::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(CMyCommandTryDlgAutoProxy, CCmdTarget)
	//{{AFX_MSG_MAP(CMyCommandTryDlgAutoProxy)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CMyCommandTryDlgAutoProxy, CCmdTarget)
	//{{AFX_DISPATCH_MAP(CMyCommandTryDlgAutoProxy)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IMyCommandTry to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {2A1FDA7D-3CD5-4378-8D4F-BFA7FEE38465}
static const IID IID_IMyCommandTry =
{ 0x2a1fda7d, 0x3cd5, 0x4378, { 0x8d, 0x4f, 0xbf, 0xa7, 0xfe, 0xe3, 0x84, 0x65 } };

BEGIN_INTERFACE_MAP(CMyCommandTryDlgAutoProxy, CCmdTarget)
	INTERFACE_PART(CMyCommandTryDlgAutoProxy, IID_IMyCommandTry, Dispatch)
END_INTERFACE_MAP()

// The IMPLEMENT_OLECREATE2 macro is defined in StdAfx.h of this project
// {E6FE8BD4-061E-4F9C-A8A7-0C6E5C7A0B40}
IMPLEMENT_OLECREATE2(CMyCommandTryDlgAutoProxy, "MyCommandTry.Application", 0xe6fe8bd4, 0x61e, 0x4f9c, 0xa8, 0xa7, 0xc, 0x6e, 0x5c, 0x7a, 0xb, 0x40)

/////////////////////////////////////////////////////////////////////////////
// CMyCommandTryDlgAutoProxy message handlers

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?