IMPLEMENT_DYNCREATE(CDFPGECtrl, COleControl)

// Message map
BEGIN_MESSAGE_MAP(CDFPGECtrl, COleControl)
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()

// Dispatch map
BEGIN_DISPATCH_MAP(CDFPGECtrl, COleControl)
	InterfaceTable(SUBMACRO_DISPATCHMAP)
END_DISPATCH_MAP()

// Event map
BEGIN_EVENT_MAP(CDFPGECtrl, COleControl)
	EVENT_STOCK_CLICK()
	EVENT_STOCK_DBLCLICK()
	EVENT_STOCK_KEYDOWN()
	EVENT_STOCK_KEYPRESS()
	EVENT_STOCK_KEYUP()
	EVENT_STOCK_MOUSEDOWN()
	EVENT_STOCK_MOUSEMOVE()
	EVENT_STOCK_MOUSEUP()
END_EVENT_MAP()

// Property pages
BEGIN_PROPPAGEIDS(CDFPGECtrl, 1)
	PROPPAGEID(CDFPGEPropPage::guid)
END_PROPPAGEIDS(CDFPGECtrl)

// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CDFPGECtrl, "DFPGE.DFPGECtrl.1",
	0x5e59055b, 0x2f49, 0x489b, 0xba, 0x8f, 0xf3, 0xc5, 0xe, 0x51, 0x78, 0x2d)

// Type library ID and version
IMPLEMENT_OLETYPELIB(CDFPGECtrl, _tlid, _wVerMajor, _wVerMinor)

// Interface IDs
const IID BASED_CODE IID_DDFPGE =
		{ 0x609D1A63, 0xF829, 0x4247, { 0x99, 0x3B, 0xE6, 0x39, 0x7F, 0x26, 0xCF, 0x5B } };
const IID BASED_CODE IID_DDFPGEEvents =
		{ 0xD1133D4E, 0xDEE6, 0x410E, { 0xBF, 0xA, 0x48, 0x8A, 0xE0, 0xAF, 0x8D, 0x92 } };

// Control type information
static const DWORD BASED_CODE _dwDFPGEOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CDFPGECtrl, IDS_DFPGE, _dwDFPGEOleMisc)

// CDFPGECtrl::CDFPGECtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CDFPGECtrl
BOOL CDFPGECtrl::CDFPGECtrlFactory::UpdateRegistry(BOOL bRegister)
{
	if (bRegister)
		return AfxOleRegisterControlClass(
			AfxGetInstanceHandle(),
			m_clsid,
			m_lpszProgID,
			IDS_DFPGE,
			IDB_DFPGE,
			afxRegDefault,
			_dwDFPGEOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
