oleinplaceobject.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:5k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * oleinplaceobject.cpp: ActiveX control for VLC
  3.  *****************************************************************************
  4.  * Copyright (C) 2005 the VideoLAN team
  5.  *
  6.  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  21.  *****************************************************************************/
  22. #include "plugin.h"
  23. #include "oleinplaceobject.h"
  24. #include <docobj.h>
  25. using namespace std;
  26. STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
  27. {
  28.     if( NULL == pHwnd )
  29.         return E_POINTER;
  30.     *pHwnd = NULL;
  31.     if( _p_instance->isInPlaceActive() )
  32.     {
  33.         if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
  34.             return S_OK;
  35.     }
  36.     return E_FAIL;
  37. };
  38. STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
  39. {
  40.     return E_NOTIMPL;
  41. };
  42. STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
  43. {
  44.     if( _p_instance->isInPlaceActive() )
  45.     {
  46.         UIDeactivate();
  47.         _p_instance->onInPlaceDeactivate();
  48.         LPOLEOBJECT p_oleObject;
  49.         if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
  50.         {
  51.             LPOLECLIENTSITE p_clientSite;
  52.             if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
  53.             {
  54.                 LPOLEINPLACESITE p_inPlaceSite;
  55.                 if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
  56.                 {
  57.                     p_inPlaceSite->OnInPlaceDeactivate();
  58.                     p_inPlaceSite->Release();
  59.                 }
  60.                 p_clientSite->Release();
  61.             }
  62.             p_oleObject->Release();
  63.         }
  64.         return S_OK;
  65.     }
  66.     return E_UNEXPECTED;
  67. };
  68. STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
  69. {
  70.     if( _p_instance->isInPlaceActive() )
  71.     {
  72.         if( _p_instance->hasFocus() )
  73.             _p_instance->setFocus(FALSE);
  74.         LPOLEOBJECT p_oleObject;
  75.         if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
  76.         {
  77.             LPOLECLIENTSITE p_clientSite;
  78.             if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
  79.             {
  80.                 LPOLEINPLACESITE p_inPlaceSite;
  81.                 if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
  82.                 {
  83.                     LPOLEINPLACEFRAME p_inPlaceFrame;
  84.                     LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
  85.                     OLEINPLACEFRAMEINFO oleFrameInfo;
  86.                     RECT posRect, clipRect;
  87.                     oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
  88.                     if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
  89.                     {
  90.                         if( p_inPlaceFrame )
  91.                         {
  92.                             p_inPlaceFrame->SetActiveObject(NULL, NULL);
  93.                             p_inPlaceFrame->Release();
  94.                         }
  95.                         if( p_inPlaceUIWindow )
  96.                         {
  97.                             p_inPlaceUIWindow->SetActiveObject(NULL, NULL);
  98.                             p_inPlaceUIWindow->Release();
  99.                         }
  100.                     }
  101.                     p_inPlaceSite->OnUIDeactivate(FALSE);
  102.                     p_inPlaceSite->Release();
  103.                 }
  104.                 p_clientSite->Release();
  105.             }
  106.             p_oleObject->Release();
  107.         }
  108.         return S_OK;
  109.     }
  110.     return E_UNEXPECTED;
  111. };
  112. STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
  113. {
  114.     if( _p_instance->isInPlaceActive() )
  115.     {
  116.         _p_instance->onPositionChange(lprcPosRect, lprcClipRect);
  117.         return S_OK;
  118.     }
  119.     return E_UNEXPECTED;
  120. };
  121. STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void)
  122. {
  123.     return INPLACE_E_NOTUNDOABLE;
  124. };