// CircCtl.h : Declaration of the CMiniCirc

#include "resource.h"       // main symbols


/////////////////////////////////////////////////////////////////////////////
// CMiniCirc
class CMiniCirc :
	public CComObjectRoot,
	public CComCoClass<CMiniCirc,&CLSID_CMiniCirc>,
	public CComControl<CMiniCirc>,
	public IDispatchImpl<IMiniCirc, &IID_IMiniCirc, &LIBID_MINICIRCLib>,
	public IPersistStreamInitImpl<CMiniCirc>,
	public IOleControlImpl<CMiniCirc>,
	public IOleObjectImpl<CMiniCirc>,
	public IOleInPlaceActiveObjectImpl<CMiniCirc>,
	public IViewObjectExImpl<CMiniCirc>,
	public IOleInPlaceObjectWindowlessImpl<CMiniCirc>
{
public:
	CMiniCirc()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_MiniCirc)


BEGIN_COM_MAP(CMiniCirc) 
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IMiniCirc)
	COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
	COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
	COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
	COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
	COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
	COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
	COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
	COM_INTERFACE_ENTRY_IMPL(IOleControl)
	COM_INTERFACE_ENTRY_IMPL(IOleObject)
	COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
END_COM_MAP()

BEGIN_PROPERTY_MAP(CMiniCirc)
	// PROP_ENTRY("Description", dispid, clsid)
	// PROP_PAGE(CLSID_CColorPropPage)
END_PROPERTY_MAP()


BEGIN_MSG_MAP(CMiniCirc)
	MESSAGE_HANDLER(WM_PAINT, OnPaint)
	MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode)
	MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
	MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
END_MSG_MAP()

// IMiniCirc
public:
	HRESULT OnDraw(ATL_DRAWINFO& di)
	{
		if (di.dwDrawAspect != DVASPECT_CONTENT)
			return E_FAIL;
		HDC hdc = di.hdcDraw;
		HDC hic = di.hicTargetDev;
		if (hic == NULL)
			hic = AtlCreateTargetDC(hdc, di.ptd);
		RECT& rc = *(RECT*)di.prcBounds;
		Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
		SetBkMode(hdc, TRANSPARENT);
		if (hic != hdc)
			DeleteDC(hic);
		return S_OK;
	}
};
