226 lines
7.2 KiB
C++
226 lines
7.2 KiB
C++
// CCActiveXCtl.h : Declaration of the CCCActiveXCtl
|
|
#pragma once
|
|
#include "resource.h" // main symbols
|
|
#include <atlctl.h>
|
|
#include "CCActiveX.h"
|
|
#include "_ICCActiveXCtlEvents_CP.h"
|
|
|
|
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
|
|
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
|
|
#endif
|
|
|
|
|
|
// CCCActiveXCtl
|
|
class ATL_NO_VTABLE CCCActiveXCtl :
|
|
public CComObjectRootEx<CComSingleThreadModel>,
|
|
public IDispatchImpl<ICCActiveXCtl, &IID_ICCActiveXCtl, &LIBID_CCActiveXLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
|
|
public IPersistStreamInitImpl<CCCActiveXCtl>,
|
|
public IOleControlImpl<CCCActiveXCtl>,
|
|
public IOleObjectImpl<CCCActiveXCtl>,
|
|
public IOleInPlaceActiveObjectImpl<CCCActiveXCtl>,
|
|
public IViewObjectExImpl<CCCActiveXCtl>,
|
|
public IOleInPlaceObjectWindowlessImpl<CCCActiveXCtl>,
|
|
public ISupportErrorInfo,
|
|
public IConnectionPointContainerImpl<CCCActiveXCtl>,
|
|
public CProxy_ICCActiveXCtlEvents<CCCActiveXCtl>,
|
|
public IPersistStorageImpl<CCCActiveXCtl>,
|
|
public ISpecifyPropertyPagesImpl<CCCActiveXCtl>,
|
|
public IQuickActivateImpl<CCCActiveXCtl>,
|
|
#ifndef _WIN32_WCE
|
|
public IDataObjectImpl<CCCActiveXCtl>,
|
|
#endif
|
|
public IProvideClassInfo2Impl<&CLSID_CCActiveXCtl, &__uuidof(_ICCActiveXCtlEvents), &LIBID_CCActiveXLib>,
|
|
#ifdef _WIN32_WCE // IObjectSafety is required on Windows CE for the control to be loaded correctly
|
|
public IObjectSafetyImpl<CCCActiveXCtl, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
|
|
#endif
|
|
public CComCoClass<CCCActiveXCtl, &CLSID_CCActiveXCtl>,
|
|
public CComControl<CCCActiveXCtl>,
|
|
public IPersistPropertyBagImpl<CCCActiveXCtl>,
|
|
public IObjectSafetyImpl<CCCActiveXCtl,
|
|
INTERFACESAFE_FOR_UNTRUSTED_CALLER |
|
|
INTERFACESAFE_FOR_UNTRUSTED_DATA>
|
|
{
|
|
public:
|
|
|
|
|
|
CCCActiveXCtl()
|
|
{
|
|
m_bWindowOnly = true; // ensures OnCreate() is called
|
|
}
|
|
|
|
DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE |
|
|
OLEMISC_CANTLINKINSIDE |
|
|
OLEMISC_INSIDEOUT |
|
|
OLEMISC_ACTIVATEWHENVISIBLE |
|
|
OLEMISC_SETCLIENTSITEFIRST
|
|
)
|
|
|
|
DECLARE_REGISTRY_RESOURCEID(IDR_CCACTIVEXCTL)
|
|
|
|
|
|
BEGIN_COM_MAP(CCCActiveXCtl)
|
|
COM_INTERFACE_ENTRY(ICCActiveXCtl)
|
|
COM_INTERFACE_ENTRY(IDispatch)
|
|
COM_INTERFACE_ENTRY(IViewObjectEx)
|
|
COM_INTERFACE_ENTRY(IViewObject2)
|
|
COM_INTERFACE_ENTRY(IViewObject)
|
|
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
|
|
COM_INTERFACE_ENTRY(IOleInPlaceObject)
|
|
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
|
|
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
|
|
COM_INTERFACE_ENTRY(IOleControl)
|
|
COM_INTERFACE_ENTRY(IOleObject)
|
|
COM_INTERFACE_ENTRY(IPersistStreamInit)
|
|
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
|
|
COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
|
COM_INTERFACE_ENTRY(IConnectionPointContainer)
|
|
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
|
|
COM_INTERFACE_ENTRY(IQuickActivate)
|
|
COM_INTERFACE_ENTRY(IPersistStorage)
|
|
COM_INTERFACE_ENTRY(IPersistPropertyBag)
|
|
COM_INTERFACE_ENTRY(IObjectSafety)
|
|
#ifndef _WIN32_WCE
|
|
COM_INTERFACE_ENTRY(IDataObject)
|
|
#endif
|
|
COM_INTERFACE_ENTRY(IProvideClassInfo)
|
|
COM_INTERFACE_ENTRY(IProvideClassInfo2)
|
|
#ifdef _WIN32_WCE // IObjectSafety is required on Windows CE for the control to be loaded correctly
|
|
COM_INTERFACE_ENTRY_IID(IID_IObjectSafety, IObjectSafety)
|
|
#endif
|
|
END_COM_MAP()
|
|
|
|
BEGIN_PROP_MAP(CCCActiveXCtl)
|
|
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
|
|
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
|
|
// Example entries
|
|
// PROP_ENTRY("Property Description", dispid, clsid)
|
|
// PROP_PAGE(CLSID_StockColorPage)
|
|
END_PROP_MAP()
|
|
|
|
BEGIN_CONNECTION_POINT_MAP(CCCActiveXCtl)
|
|
CONNECTION_POINT_ENTRY(__uuidof(_ICCActiveXCtlEvents))
|
|
END_CONNECTION_POINT_MAP()
|
|
|
|
BEGIN_MSG_MAP(CCCActiveXCtl)
|
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
|
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
|
CHAIN_MSG_MAP(CComControl<CCCActiveXCtl>)
|
|
DEFAULT_REFLECTION_HANDLER()
|
|
END_MSG_MAP()
|
|
// Handler prototypes:
|
|
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
|
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
|
|
|
|
// ISupportsErrorInfo
|
|
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
|
|
{
|
|
static const IID* arr[] =
|
|
{
|
|
&IID_ICCActiveXCtl,
|
|
};
|
|
|
|
for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
|
|
{
|
|
if (InlineIsEqualGUID(*arr[i], riid))
|
|
return S_OK;
|
|
}
|
|
return S_FALSE;
|
|
}
|
|
|
|
// IViewObjectEx
|
|
DECLARE_VIEW_STATUS(0)
|
|
|
|
// CMyControl is derived from CComControl
|
|
/*STDMETHOD(SetClientSite)(IOleClientSite *pClientSite)
|
|
{
|
|
if (pClientSite)
|
|
{
|
|
RECT rc = {0,0,0,0};
|
|
// Don't have access to the container's window so just use the
|
|
// desktop. Window will be resized correctly during in-place
|
|
// activation.
|
|
HWND hWnd = CreateControlWindow(::GetDesktopWindow(), rc);
|
|
_ASSERT (hWnd);
|
|
}
|
|
return IOleObjectImpl<CCCActiveXCtl>::SetClientSite (pClientSite);
|
|
}
|
|
|
|
HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect)
|
|
{
|
|
// Get the container's window.
|
|
_ASSERT (m_spClientSite);
|
|
LPOLEINPLACESITE pInPlaceSite = NULL;
|
|
HRESULT hr = m_spClientSite->QueryInterface(IID_IOleInPlaceSite,
|
|
(void **)&pInPlaceSite);
|
|
_ASSERT (SUCCEEDED (hr) && pInPlaceSite);
|
|
HWND hParent = NULL;
|
|
hr = pInPlaceSite->GetWindow (&hParent);
|
|
_ASSERT (SUCCEEDED (hr) && hParent);
|
|
pInPlaceSite->Release ();
|
|
// Set container window as our parent window
|
|
SetParent (hParent);
|
|
return CComControlBase::InPlaceActivate(iVerb, prcPosRect);
|
|
}*/
|
|
|
|
// ICCActiveXCtl
|
|
public:
|
|
HRESULT OnDraw(ATL_DRAWINFO& di);
|
|
/*
|
|
{
|
|
RECT& rc = *(RECT*)di.prcBounds;
|
|
// Set Clip region to the rectangle specified by di.prcBounds
|
|
HRGN hRgnOld = NULL;
|
|
if (GetClipRgn(di.hdcDraw, hRgnOld) != 1)
|
|
hRgnOld = NULL;
|
|
bool bSelectOldRgn = false;
|
|
|
|
HRGN hRgnNew = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
if (hRgnNew != NULL)
|
|
{
|
|
bSelectOldRgn = (SelectClipRgn(di.hdcDraw, hRgnNew) != ERROR);
|
|
}
|
|
|
|
Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
|
|
SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
|
|
LPCTSTR pszText = _T("ATL 8.0 : CCActiveXCtl");
|
|
#ifndef _WIN32_WCE
|
|
TextOut(di.hdcDraw,
|
|
(rc.left + rc.right) / 2,
|
|
(rc.top + rc.bottom) / 2,
|
|
pszText,
|
|
lstrlen(pszText));
|
|
#else
|
|
ExtTextOut(di.hdcDraw,
|
|
(rc.left + rc.right) / 2,
|
|
(rc.top + rc.bottom) / 2,
|
|
ETO_OPAQUE,
|
|
NULL,
|
|
pszText,
|
|
ATL::lstrlen(pszText),
|
|
NULL);
|
|
#endif
|
|
|
|
if (bSelectOldRgn)
|
|
SelectClipRgn(di.hdcDraw, hRgnOld);
|
|
|
|
return S_OK;
|
|
}*/
|
|
|
|
|
|
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
|
|
|
HRESULT FinalConstruct()
|
|
{
|
|
return S_OK;
|
|
}
|
|
|
|
void FinalRelease()
|
|
{
|
|
}
|
|
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
|
|
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
|
|
};
|
|
|
|
OBJECT_ENTRY_AUTO(__uuidof(CCActiveXCtl), CCCActiveXCtl)
|