|
// DlgProxy.cpp : implementation file
//
#include "stdafx.h"
#include "IEC2.h"
#include "DlgProxy.h"
#include "IEC2Dlg.h"
#include "EXDISPID.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIEC2DlgAutoProxy
IMPLEMENT_DYNCREATE(CIEC2DlgAutoProxy, CCmdTarget)
CIEC2DlgAutoProxy::CIEC2DlgAutoProxy()
{
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(CIEC2Dlg, AfxGetApp()->m_pMainWnd);
m_pDialog = (CIEC2Dlg*) AfxGetApp()->m_pMainWnd;
m_pDialog->m_pAutoProxy = this;
}
CIEC2DlgAutoProxy::~CIEC2DlgAutoProxy()
{
// 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 CIEC2DlgAutoProxy::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(CIEC2DlgAutoProxy, CCmdTarget)
//{{AFX_MSG_MAP(CIEC2DlgAutoProxy)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CIEC2DlgAutoProxy, CCmdTarget)
//{{AFX_DISPATCH_MAP(CIEC2DlgAutoProxy)
DISP_FUNCTION_ID(CIEC2DlgAutoProxy, "DocumentComplete", DISPID_DOCUMENTCOMPLETE, DocumentComplete, VT_EMPTY, VTS_DISPATCH VTS_PVARIANT)
DISP_FUNCTION_ID(CIEC2DlgAutoProxy, "OnQuit", DISPID_ONQUIT, OnQuit, VT_EMPTY, VTS_NONE)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_IIEC2 to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {0CEDB5A2-DA5A-4657-B7A0-174F45C75530}
static const IID IID_IIEC2 =
{ 0xcedb5a2, 0xda5a, 0x4657, { 0xb7, 0xa0, 0x17, 0x4f, 0x45, 0xc7, 0x55, 0x30 } };
BEGIN_INTERFACE_MAP(CIEC2DlgAutoProxy, CCmdTarget)
INTERFACE_PART(CIEC2DlgAutoProxy, IID_IIEC2, Dispatch)
END_INTERFACE_MAP()
// The IMPLEMENT_OLECREATE2 macro is defined in StdAfx.h of this project
// {9EDEAE6A-34F9-4774-8037-DB18663A5C2F}
IMPLEMENT_OLECREATE2(CIEC2DlgAutoProxy, "IEC2.Application", 0x9edeae6a, 0x34f9, 0x4774, 0x80, 0x37, 0xdb, 0x18, 0x66, 0x3a, 0x5c, 0x2f)
/////////////////////////////////////////////////////////////////////////////
// CIEC2DlgAutoProxy message handlers
void CIEC2DlgAutoProxy::DocumentComplete(LPDISPATCH pDisp, VARIANT FAR* URL)
{
// TODO: Add your dispatch handler code here
CComQIPtr<IUnknown,&IID_IUnknown> pIEUnk((IUnknown*)(m_pDialog->m_pIE));
CComQIPtr<IUnknown,&IID_IUnknown> pLoadedUnk(pDisp);
m_pDialog->m_pIE->get_LocationName(&bstrName);
m_pDialog->m_pIE->get_LocationURL(&bstrURL);
if(pIEUnk==pLoadedUnk)
{
m_pDialog->m_bLoaded=TRUE;
AfxMessageBox("COMPLETELY LOADED: "+(CString)bstrName+" "
+(CString)bstrURL);
}
else
{
AfxMessageBox("Inside Frame loaded: "+(CString)URL->bstrVal);
}
}
void CIEC2DlgAutoProxy::OnQuit()
{
// TODO: Add your dispatch handler code here
m_pDialog->m_bQuit=TRUE;
m_pDialog->m_pIE->put_Visible(FALSE);
AfxMessageBox("I know you quit, good-bye.");
m_pDialog->CDialog::OnCancel();
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.