Commit 1591dec0 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 de2a4a92
...@@ -28,13 +28,15 @@ ...@@ -28,13 +28,15 @@
using namespace std; using namespace std;
#define THREADING_MODEL "Both"
#define COMPANY_STR "VideoLAN" #define COMPANY_STR "VideoLAN"
#define PROGRAM_STR "VLCPlugin" #define PROGRAM_STR "VLCPlugin"
#define VERSION_MAJOR_STR "1" #define VERSION_MAJOR_STR "1"
#define VERSION_MINOR_STR "0" #define VERSION_MINOR_STR "0"
#define DESCRIPTION "VideoLAN VLC ActiveX Plugin" #define DESCRIPTION "VideoLAN VLC ActiveX Plugin"
#define THREADING_MODEL "Apartment"
#define MISC_STATUS "131473"
#define PROGID_STR COMPANY_STR"."PROGRAM_STR #define PROGID_STR COMPANY_STR"."PROGRAM_STR
#define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR #define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR
#define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR #define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR
...@@ -193,7 +195,7 @@ STDAPI DllRegisterServer(VOID) ...@@ -193,7 +195,7 @@ STDAPI DllRegisterServer(VOID)
// MiscStatus key value // MiscStatus key value
hSubKey = keyCreate(hClassKey, TEXT("MiscStatus\\1")); 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); RegCloseKey(hSubKey);
// Programmable key value // Programmable key value
......
...@@ -65,13 +65,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi ...@@ -65,13 +65,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
case OLEIVERB_SHOW: case OLEIVERB_SHOW:
case OLEIVERB_OPEN: case OLEIVERB_OPEN:
case OLEIVERB_INPLACEACTIVATE: case OLEIVERB_INPLACEACTIVATE:
if( NULL == hwndParent ) return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect);
return OLEOBJ_S_INVALIDHWND;
if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )
return S_OK;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
case OLEIVERB_HIDE: case OLEIVERB_HIDE:
_p_instance->setVisible(FALSE); _p_instance->setVisible(FALSE);
...@@ -84,13 +78,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi ...@@ -84,13 +78,7 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
return S_OK; return S_OK;
default: default:
if( NULL == hwndParent ) return OLEOBJ_S_INVALIDVERB;
return OLEOBJ_S_INVALIDHWND;
if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )
return OLEOBJ_S_INVALIDVERB;
return OLEOBJ_S_CANNOT_DOVERB_NOW;
} }
}; };
...@@ -116,7 +104,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite ...@@ -116,7 +104,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{ {
if( S_OK != p_inPlaceSite->CanInPlaceActivate() ) if( S_OK != p_inPlaceSite->CanInPlaceActivate() )
return E_FAIL; return OLEOBJ_S_CANNOT_DOVERB_NOW;
LPOLEINPLACEFRAME p_inPlaceFrame; LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow; LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
...@@ -132,10 +120,22 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite ...@@ -132,10 +120,22 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
if( NULL != p_inPlaceUIWindow ) if( NULL != p_inPlaceUIWindow )
p_inPlaceUIWindow->Release(); 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)) ) 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 ) if( NULL != p_inPlaceSite )
p_inPlaceSite->OnPosRectChange(lprcPosRect); p_inPlaceSite->OnPosRectChange(lprcPosRect);
...@@ -163,7 +163,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite ...@@ -163,7 +163,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
} }
return S_OK; return S_OK;
} }
return E_FAIL; return OLEOBJ_S_CANNOT_DOVERB_NOW;
}; };
HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect)
...@@ -214,7 +214,7 @@ STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite) ...@@ -214,7 +214,7 @@ STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite)
if( NULL != _p_clientsite ) if( NULL != _p_clientsite )
_p_clientsite->AddRef(); _p_clientsite->AddRef();
*ppClientSite= _p_clientsite; *ppClientSite = _p_clientsite;
return S_OK; return S_OK;
}; };
...@@ -302,8 +302,8 @@ STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite) ...@@ -302,8 +302,8 @@ STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
VariantClear(&v); VariantClear(&v);
} }
} }
_p_clientsite = pClientSite; _p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
return S_OK; return S_OK;
}; };
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "persistpropbag.h" #include "persistpropbag.h"
#include "utils.h" #include "utils.h"
#include "oleobject.h"
using namespace std; using namespace std;
...@@ -39,7 +40,7 @@ STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID) ...@@ -39,7 +40,7 @@ STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistPropertyBag::InitNew(void) STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
{ {
return _p_instance->onInitNew(); return _p_instance->onInit(TRUE);
}; };
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog) STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
...@@ -47,7 +48,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr ...@@ -47,7 +48,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
if( NULL == pPropBag ) if( NULL == pPropBag )
return E_POINTER; return E_POINTER;
HRESULT hr = _p_instance->onInitNew(); HRESULT hr = _p_instance->onInit(FALSE);
if( FAILED(hr) ) if( FAILED(hr) )
return hr; return hr;
...@@ -112,7 +113,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr ...@@ -112,7 +113,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
VariantClear(&value); VariantClear(&value);
} }
return S_OK; return _p_instance->onLoad();
}; };
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties) STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties)
......
...@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg) ...@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
if( NULL == pStg ) if( NULL == pStg )
return E_POINTER; return E_POINTER;
return _p_instance->onInitNew(); return _p_instance->onInit(TRUE);
}; };
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
...@@ -53,7 +53,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) ...@@ -53,7 +53,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
if( NULL == pStg ) if( NULL == pStg )
return E_POINTER; return E_POINTER;
return _p_instance->onInitNew(); return _p_instance->onInit(TRUE);
}; };
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
......
...@@ -37,7 +37,7 @@ STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID) ...@@ -37,7 +37,7 @@ STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStreamInit::InitNew(void) STDMETHODIMP VLCPersistStreamInit::InitNew(void)
{ {
return _p_instance->onInitNew(); return _p_instance->onInit(TRUE);
}; };
STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm) STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
...@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm) ...@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
if( NULL == pStm ) if( NULL == pStm )
return E_POINTER; return E_POINTER;
return _p_instance->onInitNew(); return _p_instance->onInit(TRUE);
}; };
STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty) STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)
......
...@@ -484,7 +484,9 @@ void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect) ...@@ -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 ) if( 0 == _i_vlc )
{ {
...@@ -519,11 +521,58 @@ HRESULT VLCPlugin::onInitNew(void) ...@@ -519,11 +521,58 @@ HRESULT VLCPlugin::onInitNew(void)
_i_vlc = 0; _i_vlc = 0;
return E_FAIL; 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 S_OK;
} }
return E_UNEXPECTED; 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) HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
{ {
if( _i_vlc ) if( _i_vlc )
......
...@@ -84,7 +84,9 @@ public: ...@@ -84,7 +84,9 @@ public:
REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; }; REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; }; 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); HRESULT onClose(DWORD dwSaveOption);
BOOL isInPlaceActive(void); 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