зеркало из https://github.com/mozilla/pjs.git
ActiveX control site
This commit is contained in:
Родитель
33892f7c8f
Коммит
6f9e93702b
|
@ -0,0 +1,260 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ControlSite.h"
|
||||
|
||||
CControlSite::CControlSite()
|
||||
{
|
||||
m_hwndParent = NULL;
|
||||
m_bSetClientSiteFirst = FALSE;
|
||||
m_bVisibleAtRuntime = TRUE;
|
||||
memset(&m_rcObjectPos, 0, sizeof(m_rcObjectPos));
|
||||
|
||||
m_bInPlaceActive = FALSE;
|
||||
m_bUIActive = FALSE;
|
||||
m_bInPlaceLocked = FALSE;
|
||||
}
|
||||
|
||||
CControlSite::~CControlSite()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CControlSite::InitNew(REFCLSID clsid)
|
||||
{
|
||||
// TODO see if object is script safe
|
||||
|
||||
// Create the object
|
||||
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void **) &m_spObject);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_spIViewObject = m_spObject;
|
||||
m_spIOleObject = m_spObject;
|
||||
|
||||
if (m_spIOleObject == NULL)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
DWORD dwMiscStatus;
|
||||
m_spIOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
|
||||
|
||||
if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
|
||||
{
|
||||
m_bSetClientSiteFirst = TRUE;
|
||||
}
|
||||
if (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME)
|
||||
{
|
||||
m_bVisibleAtRuntime = FALSE;
|
||||
}
|
||||
|
||||
// Some objects like to have the client site as the first thing
|
||||
// to be initialised (for ambient properties and so forth)
|
||||
if (m_bSetClientSiteFirst)
|
||||
{
|
||||
m_spIOleObject->SetClientSite(this);
|
||||
}
|
||||
|
||||
// TODO load the control from store
|
||||
|
||||
// In-place activate the object
|
||||
if (m_bVisibleAtRuntime)
|
||||
{
|
||||
DoVerb(OLEIVERB_INPLACEACTIVATE);
|
||||
}
|
||||
|
||||
// For those objects which haven't had their client site set yet,
|
||||
// it's done here.
|
||||
if (!m_bSetClientSiteFirst)
|
||||
{
|
||||
m_spIOleObject->SetClientSite(this);
|
||||
}
|
||||
|
||||
// TODO create new
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CControlSite::DoVerb(LONG nVerb, LPMSG lpMsg)
|
||||
{
|
||||
if (m_spIOleObject == NULL)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return m_spIOleObject->DoVerb(nVerb, lpMsg, this, 0, m_hwndParent, &m_rcObjectPos);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CControlSite::SetObjectPos(const RECT &rcPos)
|
||||
{
|
||||
m_rcObjectPos = rcPos;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IOleWindow implementation
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd)
|
||||
{
|
||||
*phwnd = m_hwndParent;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IOleClientSite implementation
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::SaveObject(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer)
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::ShowObject(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnShowWindow(/* [in] */ BOOL fShow)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::RequestNewObjectLayout(void)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IOleInPlaceSite implementation
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::CanInPlaceActivate(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceActivate(void)
|
||||
{
|
||||
m_bInPlaceActive = TRUE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnUIActivate(void)
|
||||
{
|
||||
m_bUIActive = TRUE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::Scroll(/* [in] */ SIZE scrollExtant)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnUIDeactivate(/* [in] */ BOOL fUndoable)
|
||||
{
|
||||
m_bUIActive = FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceDeactivate(void)
|
||||
{
|
||||
m_bInPlaceActive = FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::DiscardUndoState(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::DeactivateAndUndo(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnPosRectChange(/* [in] */ LPCRECT lprcPosRect)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IOleControlSite implementation
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnControlInfoChanged(void)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::LockInPlaceActive(/* [in] */ BOOL fLock)
|
||||
{
|
||||
m_bInPlaceLocked = fLock;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::OnFocus(/* [in] */ BOOL fGotFocus)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CControlSite::ShowPropertyFrame(void)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef CACTIVESITE_H
|
||||
#define CACTIVESITE_H
|
||||
|
||||
class CControlSite : public CComObjectRootEx<CComSingleThreadModel>,
|
||||
public IOleClientSite,
|
||||
public IOleInPlaceSite,
|
||||
public IOleControlSite
|
||||
{
|
||||
// Handle to parent window
|
||||
HWND m_hwndParent;
|
||||
// Position of the site and the contained object
|
||||
RECT m_rcObjectPos;
|
||||
// Flag indicating if client site should be set early or late
|
||||
BOOL m_bSetClientSiteFirst;
|
||||
// Flag indicating whether control is visible or not
|
||||
BOOL m_bVisibleAtRuntime;
|
||||
// Flag indicating if control is in-place active
|
||||
BOOL m_bInPlaceActive;
|
||||
// Flag indicating if control is UI active
|
||||
BOOL m_bUIActive;
|
||||
// Flag indicating if control is in-place locked and cannot be deactivated
|
||||
BOOL m_bInPlaceLocked;
|
||||
|
||||
// Raw pointer to the object
|
||||
CComPtr<IUnknown> m_spObject;
|
||||
// Pointer to objects IViewObject interface
|
||||
CComQIPtr<IViewObject, &IID_IViewObject> m_spIViewObject;
|
||||
// Pointer to objects IOleObject interface
|
||||
CComQIPtr<IOleObject, &IID_IOleObject> m_spIOleObject;
|
||||
|
||||
public:
|
||||
CControlSite();
|
||||
virtual ~CControlSite();
|
||||
|
||||
//DECLARE_REGISTRY_RESOURCEID(IDR_MOZILLABROWSER)
|
||||
|
||||
BEGIN_COM_MAP(CControlSite)
|
||||
COM_INTERFACE_ENTRY(IOleWindow)
|
||||
COM_INTERFACE_ENTRY(IOleClientSite)
|
||||
COM_INTERFACE_ENTRY(IOleInPlaceSite)
|
||||
COM_INTERFACE_ENTRY(IOleControlSite)
|
||||
END_COM_MAP()
|
||||
|
||||
|
||||
virtual HRESULT InitNew(REFCLSID clsid);
|
||||
virtual HRESULT SetObjectPos(const RECT &rcPos);
|
||||
virtual HRESULT DoVerb(LONG nVerb, LPMSG lpMsg = NULL);
|
||||
|
||||
// IOleWindow implementation
|
||||
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd);
|
||||
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode);
|
||||
|
||||
// IOleClientSite implementation
|
||||
virtual HRESULT STDMETHODCALLTYPE SaveObject(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk);
|
||||
virtual HRESULT STDMETHODCALLTYPE GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer);
|
||||
virtual HRESULT STDMETHODCALLTYPE ShowObject(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnShowWindow(/* [in] */ BOOL fShow);
|
||||
virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void);
|
||||
|
||||
// IOleInPlaceSite implementation
|
||||
virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnUIActivate(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo);
|
||||
virtual HRESULT STDMETHODCALLTYPE Scroll(/* [in] */ SIZE scrollExtant);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(/* [in] */ BOOL fUndoable);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE DiscardUndoState(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(/* [in] */ LPCRECT lprcPosRect);
|
||||
|
||||
// IOleControlSite implementation
|
||||
virtual HRESULT STDMETHODCALLTYPE OnControlInfoChanged(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE LockInPlaceActive(/* [in] */ BOOL fLock);
|
||||
virtual HRESULT STDMETHODCALLTYPE GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp);
|
||||
virtual HRESULT STDMETHODCALLTYPE TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags);
|
||||
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers);
|
||||
virtual HRESULT STDMETHODCALLTYPE OnFocus(/* [in] */ BOOL fGotFocus);
|
||||
virtual HRESULT STDMETHODCALLTYPE ShowPropertyFrame( void);
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче