📄 control.cpp
字号:
{
--m_cRef;
return m_pUnkOuter->Release();
}
/*
* CImpIPolylineControl::BackColor
* CImpIPolylineControl::LineColor
* CImpIPolylineControl::LineStyle
* CImpIPolylineControl::Clear
* CImpIPolylineControl::RemoveLastPoint
*
* Purpose:
* Dispatch interface entry points that map to IPolyline
* members.
*/
STDMETHODIMP_(void) CImpIPolylineControl::put_BackColor
(OLE_COLOR cr)
{
COLORREF crOld;
m_pObj->m_pImpIPolyline->ColorSet(POLYLINECOLOR_BACKGROUND
, cr, &crOld);
return;
}
STDMETHODIMP_(OLE_COLOR) CImpIPolylineControl::get_BackColor(void)
{
COLORREF cr;
m_pObj->m_pImpIPolyline->ColorGet(POLYLINECOLOR_BACKGROUND
, &cr);
return cr;
}
STDMETHODIMP_(void) CImpIPolylineControl::put_LineColor
(OLE_COLOR cr)
{
COLORREF crOld;
m_pObj->m_pImpIPolyline->ColorSet(POLYLINECOLOR_LINE
, cr, &crOld);
return;
}
STDMETHODIMP_(OLE_COLOR) CImpIPolylineControl::get_LineColor(void)
{
COLORREF cr;
m_pObj->m_pImpIPolyline->ColorGet(POLYLINECOLOR_LINE, &cr);
return cr;
}
STDMETHODIMP_(void) CImpIPolylineControl::put_LineStyle
(short iStyle)
{
UINT i;
m_pObj->m_pImpIPolyline->LineStyleSet(iStyle, &i);
return;
}
STDMETHODIMP_(short) CImpIPolylineControl::get_LineStyle(void)
{
UINT iStyle;
m_pObj->m_pImpIPolyline->LineStyleGet(&iStyle);
return (short)iStyle;
}
STDMETHODIMP CImpIPolylineControl::Clear(void)
{
return m_pObj->m_pImpIPolyline->New();
}
STDMETHODIMP CImpIPolylineControl::RemoveLastPoint(void)
{
return m_pObj->m_pImpIPolyline->Undo();
}
//IOleControl interface implementation
/*
* CImpIOleControl::CImpIOleControl
* CImpIOleControl::~CImpIOleControl
*
* Parameters (Constructor):
* pObj PCPolyline of the object we're in.
* pUnkOuter LPUNKNOWN to which we delegate.
*/
CImpIOleControl::CImpIOleControl(PCPolyline pObj
, LPUNKNOWN pUnkOuter)
{
m_cRef=0;
m_pObj=pObj;
m_pUnkOuter=pUnkOuter;
return;
}
CImpIOleControl::~CImpIOleControl(void)
{
return;
}
/*
* CImpIOleControl::QueryInterface
* CImpIOleControl::AddRef
* CImpIOleControl::Release
*/
STDMETHODIMP CImpIOleControl::QueryInterface(REFIID riid
, LPVOID *ppv)
{
return m_pUnkOuter->QueryInterface(riid, ppv);
}
STDMETHODIMP_(ULONG) CImpIOleControl::AddRef(void)
{
++m_cRef;
return m_pUnkOuter->AddRef();
}
STDMETHODIMP_(ULONG) CImpIOleControl::Release(void)
{
--m_cRef;
return m_pUnkOuter->Release();
}
/*
* CImpIOleControl::GetControlInfo
*
* Purpose:
* Fills a CONTROLINFO structure containing information about
* the controls mnemonics and other behavioral aspects.
*
* Parameters:
* pCI LPCONTROLINFO to the structure to fill
*/
STDMETHODIMP CImpIOleControl::GetControlInfo(LPCONTROLINFO pCI)
{
if (NULL==pCI)
return ResultFromScode(E_INVALIDARG);
*pCI=m_pObj->m_ctrlInfo;
return ResultFromScode(E_NOTIMPL);
}
/*
* CImpIOleControl::OnMnemonic
*
* Purpose:
* Notifies the control that a mnemonic was activated.
*
* Parameters:
* pMsg LPMSG containing the message that matches one of
* the control's mnemonics. The control uses this
* to distinguish which mnemonic was pressed.
*/
STDMETHODIMP CImpIOleControl::OnMnemonic(LPMSG pMsg)
{
//No mnemonics
return NOERROR;
}
/*
* CImpIOleControl::OnAmbientPropertyChange
*
* Purpose:
* Notifies the control that one or more of the container's ambient
* properties changed.
*
* Parameters:
* dispID DISPID identifying the property, which can
* be DISPID_UNKNOWN indicating that more than
* one changed.
*/
STDMETHODIMP CImpIOleControl::OnAmbientPropertyChange(DISPID dispID)
{
/*
* We detect any change in UIDead or ShowHatching. Changes
* in container colors do not affect us as we only use those
* for initial values.
*/
switch (dispID)
{
case DISPID_UNKNOWN:
m_pObj->AmbientsInitialize(INITAMBIENT_SHOWHATCHING
| INITAMBIENT_UIDEAD);
break;
case DISPID_AMBIENT_SHOWHATCHING:
m_pObj->AmbientsInitialize(INITAMBIENT_SHOWHATCHING);
break;
case DISPID_AMBIENT_UIDEAD:
m_pObj->AmbientsInitialize(INITAMBIENT_UIDEAD);
break;
}
return NOERROR;
}
/*
* CImpIOleControl::FreezeEvents
*
* Purpose:
* Instructs the control to stop firing events or to continue
* firing them.
*
* Parameters:
* fFreeze BOOL indicating to freeze (TRUE) or thaw (FALSE)
* events from this control.
*/
STDMETHODIMP CImpIOleControl::FreezeEvents(BOOL fFreeze)
{
m_pObj->m_fFreezeEvents=fFreeze;
return NOERROR;
}
//CAdviseRouter class implementation
/*
* CAdviseRouter::CAdviseRouter
* CAdviseRouter::~CAdviseRouter
*
* Constructor Parameters:
* pIDispatch IDispatch * to which we route notifications.
* pObj PCPolyline to the control itself.
*/
CAdviseRouter::CAdviseRouter(IDispatch *pIDispatch
, PCPolyline pObj)
{
m_cRef=0;
m_pObj=pObj;
m_pIDispatch=pIDispatch;
return;
}
CAdviseRouter::~CAdviseRouter(void)
{
ReleaseInterface(m_pIDispatch);
return;
}
/*
* CAdviseRouter::QueryInterface
* CAdviseRouter::AddRef
* CAdviseRouter::Release
*
* Purpose:
* IUnknown members for this IPolylineAdviseSink implementations.
*/
STDMETHODIMP CAdviseRouter::QueryInterface(REFIID riid
, PPVOID ppv)
{
*ppv=NULL;
if (IID_IUnknown==riid || IID_IPolylineAdviseSink10==riid)
{
*ppv=this;
AddRef();
return NOERROR;
}
return ResultFromScode(E_NOINTERFACE);
}
STDMETHODIMP_(ULONG) CAdviseRouter::AddRef(void)
{
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CAdviseRouter::Release(void)
{
if (0L!=--m_cRef)
return m_cRef;
delete this;
return 0;
}
/*
* CAdviseRouter::OnPointChange
* CAdviseRouter::OnSizeChange
* CAdviseRouter::OnColorChange
* CAdviseRouter::OnLineStyleChange
*
* Purpose:
* Invokes the same member in the IDispatch pointer we hold.
*/
STDMETHODIMP_(void) CAdviseRouter::OnPointChange(void)
{
Invoke(EVENT_ONPOINTCHANGE);
return;
}
STDMETHODIMP_(void) CAdviseRouter::OnSizeChange(void)
{
Invoke(EVENT_ONSIZECHANGE);
return;
}
STDMETHODIMP_(void) CAdviseRouter::OnColorChange(void)
{
Invoke(EVENT_ONCOLORCHANGE);
return;
}
STDMETHODIMP_(void) CAdviseRouter::OnLineStyleChange(void)
{
Invoke(EVENT_ONLINESTYLECHANGE);
return;
}
/*
* CAdviseRouter::Invoke
*
* Purpose:
* Calls IDispatch::Invoke for any of the events we handle.
* None of these have any arguments.
*
* Parameters:
* dispID DISPID of the event to fire.
*
* Return Value:
* None
*/
void CAdviseRouter::Invoke(DISPID dispID)
{
DISPPARAMS dp;
VARIANT va;
if (m_pObj->m_fFreezeEvents)
return;
m_pIDispatch->Invoke(dispID, IID_NULL
, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dp
, &va, NULL, NULL);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -