
// DlgProxy.cpp : implementation file
//

#include "stdafx.h"
#include "DLP_Control.h"
#include "DlgProxy.h"
#include "DLP_ControlDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CDLP_ControlDlgAutoProxy

IMPLEMENT_DYNCREATE(CDLP_ControlDlgAutoProxy, CCmdTarget)

CDLP_ControlDlgAutoProxy::CDLP_ControlDlgAutoProxy()
{
	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_VALID(AfxGetApp()->m_pMainWnd);
	if (AfxGetApp()->m_pMainWnd)
	{
		ASSERT_KINDOF(CDLP_ControlDlg, AfxGetApp()->m_pMainWnd);
		if (AfxGetApp()->m_pMainWnd->IsKindOf(RUNTIME_CLASS(CDLP_ControlDlg)))
		{
			m_pDialog = reinterpret_cast<CDLP_ControlDlg*>(AfxGetApp()->m_pMainWnd);
			m_pDialog->m_pAutoProxy = this;
		}
	}
}

CDLP_ControlDlgAutoProxy::~CDLP_ControlDlgAutoProxy()
{
	// 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 CDLP_ControlDlgAutoProxy::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(CDLP_ControlDlgAutoProxy, CCmdTarget)
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CDLP_ControlDlgAutoProxy, CCmdTarget)
END_DISPATCH_MAP()

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

// {3297AAFC-534C-4E87-909C-7FD5C7170ECA}
static const IID IID_IDLP_Control =
{ 0x3297AAFC, 0x534C, 0x4E87, { 0x90, 0x9C, 0x7F, 0xD5, 0xC7, 0x17, 0xE, 0xCA } };

BEGIN_INTERFACE_MAP(CDLP_ControlDlgAutoProxy, CCmdTarget)
	INTERFACE_PART(CDLP_ControlDlgAutoProxy, IID_IDLP_Control, Dispatch)
END_INTERFACE_MAP()

// The IMPLEMENT_OLECREATE2 macro is defined in StdAfx.h of this project
// {A01FB897-2D53-4001-B5D5-955AA952F3C8}
IMPLEMENT_OLECREATE2(CDLP_ControlDlgAutoProxy, "DLP_Control.Application", 0xa01fb897, 0x2d53, 0x4001, 0xb5, 0xd5, 0x95, 0x5a, 0xa9, 0x52, 0xf3, 0xc8)


// CDLP_ControlDlgAutoProxy message handlers
