Commit 9591f955 authored by Damien Fouilleul's avatar Damien Fouilleul

- activate (make visible) as soon as embedded into a container, no longer wait...

- activate (make visible) as soon as embedded into a container, no longer wait for container to do the activation

This fixes an annoying Internet Explorer optimization which would make the activex control invisible till a user moves the mouse over it
parent f77da44e
......@@ -28,13 +28,15 @@
using namespace std;
#define THREADING_MODEL "Both"
#define COMPANY_STR "VideoLAN"
#define PROGRAM_STR "VLCPlugin"
#define VERSION_MAJOR_STR "1"
#define VERSION_MINOR_STR "0"
#define DESCRIPTION "VideoLAN VLC ActiveX Plugin"
#define THREADING_MODEL "Apartment"
#define MISC_STATUS "131473"
#define PROGID_STR COMPANY_STR"."PROGRAM_STR
#define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR
#define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR
......@@ -193,7 +195,7 @@ STDAPI DllRegisterServer(VOID)
// MiscStatus key value
hSubKey = keyCreate(hClassKey, TEXT("MiscStatus\\1"));
RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (const BYTE*)"131473", sizeof("131473"));
RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (const BYTE*)MISC_STATUS, sizeof(MISC_STATUS));
RegCloseKey(hSubKey);
// Programmable key value
......
......@@ -65,13 +65,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
case OLEIVERB_SHOW:
case OLEIVERB_OPEN:
case OLEIVERB_INPLACEACTIVATE:
if( NULL == hwndParent )
return OLEOBJ_S_INVALIDHWND;
if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )
return S_OK;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect);
case OLEIVERB_HIDE:
_p_instance->setVisible(FALSE);
......@@ -84,13 +78,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
return S_OK;
default:
if( NULL == hwndParent )
return OLEOBJ_S_INVALIDHWND;
if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )
return OLEOBJ_S_INVALIDVERB;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
return OLEOBJ_S_INVALIDVERB;
}
};
......@@ -116,7 +104,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
if( S_OK != p_inPlaceSite->CanInPlaceActivate() )
return E_FAIL;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
......@@ -132,10 +120,22 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
if( NULL != p_inPlaceUIWindow )
p_inPlaceUIWindow->Release();
}
if( (NULL == hwndParent) && FAILED(p_inPlaceSite->GetWindow(&hwndParent)) )
{
p_inPlaceSite->Release();
return OLEOBJ_S_INVALIDHWND;
}
}
else if( NULL == hwndParent )
return OLEOBJ_S_INVALIDHWND;
if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )
return E_FAIL;
{
if( NULL != p_inPlaceSite )
p_inPlaceSite->Release();
return OLEOBJ_S_CANNOT_DOVERB_NOW;
}
if( NULL != p_inPlaceSite )
p_inPlaceSite->OnPosRectChange(lprcPosRect);
......@@ -163,7 +163,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
}
return S_OK;
}
return E_FAIL;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
};
HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect)
......@@ -214,7 +214,7 @@ STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite)
if( NULL != _p_clientsite )
_p_clientsite->AddRef();
*ppClientSite= _p_clientsite;
*ppClientSite = _p_clientsite;
return S_OK;
};
......@@ -302,8 +302,8 @@ STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
VariantClear(&v);
}
}
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
return S_OK;
};
......
......@@ -24,6 +24,7 @@
#include "persistpropbag.h"
#include "utils.h"
#include "oleobject.h"
using namespace std;
......@@ -39,7 +40,7 @@ STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
{
return _p_instance->onInitNew();
return _p_instance->onInit(TRUE);
};
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
......@@ -47,7 +48,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
if( NULL == pPropBag )
return E_POINTER;
HRESULT hr = _p_instance->onInitNew();
HRESULT hr = _p_instance->onInit(FALSE);
if( FAILED(hr) )
return hr;
......@@ -112,7 +113,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
VariantClear(&value);
}
return S_OK;
return _p_instance->onLoad();
};
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties)
......
......@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInitNew();
return _p_instance->onInit(TRUE);
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
......@@ -53,7 +53,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInitNew();
return _p_instance->onInit(TRUE);
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
......
......@@ -37,7 +37,7 @@ STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStreamInit::InitNew(void)
{
return _p_instance->onInitNew();
return _p_instance->onInit(TRUE);
};
STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
......@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
if( NULL == pStm )
return E_POINTER;
return _p_instance->onInitNew();
return _p_instance->onInit(TRUE);
};
STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)
......
......@@ -484,7 +484,9 @@ void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect)
}
};
HRESULT VLCPlugin::onInitNew(void)
#include <iostream>
HRESULT VLCPlugin::onInit(BOOL isNew)
{
if( 0 == _i_vlc )
{
......@@ -519,11 +521,58 @@ HRESULT VLCPlugin::onInitNew(void)
_i_vlc = 0;
return E_FAIL;
}
if( isNew )
{
/*
** object has fully initialized,
** try to activate in place if container is ready
*/
LPOLECLIENTSITE pActiveSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) )
{
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL);
pActiveSite->Release();
}
}
return S_OK;
}
return E_UNEXPECTED;
};
HRESULT VLCPlugin::onLoad(void)
{
/*
** object has fully initialized,
** try to activate in place if container is ready
*/
LPOLECLIENTSITE pActiveSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) )
{
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL);
pActiveSite->Release();
}
return S_OK;
};
HRESULT VLCPlugin::onClientSiteChanged(LPOLECLIENTSITE pActiveSite)
{
if( NULL != pActiveSite )
{
/*
** object is embedded in container
** try to activate in place if it has initialized
*/
if( _i_vlc )
{
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL);
}
}
return S_OK;
};
HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
{
if( _i_vlc )
......
......@@ -84,7 +84,9 @@ public:
REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
HRESULT onInitNew(void);
HRESULT onInit(BOOL isNew);
HRESULT onLoad(void);
HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
HRESULT onClose(DWORD dwSaveOption);
BOOL isInPlaceActive(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment