PLUGINC.CPP

// PluginC.cpp : Implementation of the CPluginCtrl OLE control class. 

#include "stdafx.h"
#include "plugin.h"
#include "PluginC.h"
#include "PluginP.h"


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


IMPLEMENT_DYNCREATE(CPluginCtrl, COleControl)


/////////////////////////////////////////////////////////////////////////////
// Message map

BEGIN_MESSAGE_MAP(CPluginCtrl, COleControl)
//{{AFX_MSG_MAP(CPluginCtrl)
// NOTE - ClassWizard will add and remove message map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// Dispatch map

BEGIN_DISPATCH_MAP(CPluginCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CPluginCtrl)
DISP_FUNCTION(CPluginCtrl, "MprUISetContext", MprUISetContext, VT_I4, VTS_I4 VTS_I4)
DISP_FUNCTION(CPluginCtrl, "MprUIRefresh", MprUIRefresh, VT_I4, VTS_NONE)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()


/////////////////////////////////////////////////////////////////////////////
// Event map

BEGIN_EVENT_MAP(CPluginCtrl, COleControl)
//{{AFX_EVENT_MAP(CPluginCtrl)
// NOTE - ClassWizard will add and remove event map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_EVENT_MAP
END_EVENT_MAP()


/////////////////////////////////////////////////////////////////////////////
// Property pages

// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(CPluginCtrl, 1)
PROPPAGEID(CPluginPropPage::guid)
END_PROPPAGEIDS(CPluginCtrl)


/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CPluginCtrl, "PLUGIN.PluginCtrl.1",
0x85df114, 0x10e, 0x11d0, 0xaa, 0x6b, 0, 0x80, 0x5f, 0xc, 0x92, 0x32)


/////////////////////////////////////////////////////////////////////////////
// Type library ID and version

IMPLEMENT_OLETYPELIB(CPluginCtrl, _tlid, _wVerMajor, _wVerMinor)


/////////////////////////////////////////////////////////////////////////////
// Interface IDs

const IID BASED_CODE IID_DPlugin =
{ 0x85df112, 0x10e, 0x11d0, { 0xaa, 0x6b, 0, 0x80, 0x5f, 0xc, 0x92, 0x32 } };
const IID BASED_CODE IID_DPluginEvents =
{ 0x85df113, 0x10e, 0x11d0, { 0xaa, 0x6b, 0, 0x80, 0x5f, 0xc, 0x92, 0x32 } };


/////////////////////////////////////////////////////////////////////////////
// Control type information

static const DWORD BASED_CODE _dwPluginOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CPluginCtrl, IDS_PLUGIN, _dwPluginOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::CPluginCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CPluginCtrl

BOOL CPluginCtrl::CPluginCtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0.

if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_PLUGIN,
IDB_PLUGIN,
afxRegApartmentThreading,
_dwPluginOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::CPluginCtrl - Constructor

CPluginCtrl::CPluginCtrl()
{
InitializeIIDs(&IID_DPlugin, &IID_DPluginEvents);

// TODO: Initialize your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::~CPluginCtrl - Destructor

CPluginCtrl::~CPluginCtrl()
{
// TODO: Cleanup your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::OnDraw - Drawing function

void CPluginCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
pdc->Ellipse(rcBounds);
}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::DoPropExchange - Persistence support

void CPluginCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);

// TODO: Call PX_ functions for each persistent custom property.

}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl::OnResetState - Reset control to default state

void CPluginCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange

// TODO: Reset any other control state here.
}


/////////////////////////////////////////////////////////////////////////////
// CPluginCtrl message handlers

long CPluginCtrl::MprUISetContext(long lNode, long lContext)
{
// TODO: Add your dispatch handler code here

return 0;
}

long CPluginCtrl::MprUIRefresh()
{
// TODO: Add your dispatch handler code here

return 0;
}