1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-13 02:40:52 +02:00

all: clean-up, bug fixes so that plugin is now working correctly with Visual Basic 6 (which I have tested) and hopefully should also work with .NET (which I havent't tested).

Outstanding issue: the control properties are not persisted

vlc16x16.bmp: toolbar icon for VLC plugin
This commit is contained in:
Damien Fouilleul 2005-06-27 11:41:16 +00:00
parent da5c4157bb
commit da4dc63b33
12 changed files with 114 additions and 134 deletions

View File

@ -52,6 +52,7 @@ DIST_misc = \
axvlc.idl \ axvlc.idl \
axvlc.tlb \ axvlc.tlb \
inplace.bmp \ inplace.bmp \
vlc16x16.bmp \
test.html \ test.html \
$(NULL) $(NULL)

View File

@ -8,6 +8,7 @@
#define STRINGIFY( z ) UGLY_KLUDGE( z ) #define STRINGIFY( z ) UGLY_KLUDGE( z )
#define UGLY_KLUDGE( z ) #z #define UGLY_KLUDGE( z ) #z
1 BITMAP "vlc16x16.bmp"
1 VERSIONINFO 1 VERSIONINFO
FILETYPE 1 FILETYPE 1
FILEOS 4 FILEOS 4

View File

@ -186,6 +186,14 @@ STDAPI DllRegisterServer(VOID)
hSubKey = keyCreate(hClassKey, TEXT("Control")); hSubKey = keyCreate(hClassKey, TEXT("Control"));
RegCloseKey(hSubKey); RegCloseKey(hSubKey);
// ToolboxBitmap32 key value
hSubKey = keyCreate(hClassKey, TEXT("ToolboxBitmap32"));
strcpy(DllPath+DllPathLen, ",1");
RegSetValueEx(hSubKey, NULL, 0, REG_SZ,
(const BYTE*)DllPath, DllPathLen+2);
DllPath[DllPathLen] = '\0';
RegCloseKey(hSubKey);
#ifdef BUILD_LOCALSERVER #ifdef BUILD_LOCALSERVER
// LocalServer32 key value // LocalServer32 key value
hSubKey = keyCreate(hClassKey, TEXT("LocalServer32")); hSubKey = keyCreate(hClassKey, TEXT("LocalServer32"));

View File

@ -56,9 +56,6 @@ STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect) LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect)
{ {
if( 0 != lIndex )
return DV_E_LINDEX;
switch( iVerb ) switch( iVerb )
{ {
case OLEIVERB_PRIMARY: case OLEIVERB_PRIMARY:
@ -104,7 +101,9 @@ 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 OLEOBJ_S_CANNOT_DOVERB_NOW; return OLEOBJ_S_CANNOT_DOVERB_NOW;
}
LPOLEINPLACEFRAME p_inPlaceFrame; LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow; LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
@ -128,7 +127,9 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
} }
} }
else if( NULL == hwndParent ) else if( NULL == hwndParent )
{
return OLEOBJ_S_INVALIDHWND; return OLEOBJ_S_INVALIDHWND;
}
if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) ) if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )
{ {
@ -293,8 +294,6 @@ STDMETHODIMP VLCOleObject::IsUpToDate(void)
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite) STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{ {
if( NULL != _p_clientsite )
_p_clientsite->Release();
if( NULL != pClientSite ) if( NULL != pClientSite )
{ {
@ -312,8 +311,13 @@ STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
VariantClear(&v); VariantClear(&v);
} }
} }
if( NULL != _p_clientsite )
_p_clientsite->Release();
_p_clientsite = pClientSite; _p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite); _p_instance->onClientSiteChanged(pClientSite);
return S_OK; return S_OK;
}; };
@ -337,30 +341,18 @@ STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel)
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{ {
LPOLECONTROLSITE p_controlSite; HWND hwnd;
RECT posRect = _p_instance->getPosRect();
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleControlSite, (void**)&p_controlSite)) ) if( SUCCEEDED(p_inPlaceSite->GetWindow(&hwnd)) )
{ {
// use HIMETRIC to container transform // use HIMETRIC to pixel transform
POINTL extent = { pSizel->cx, pSizel->cy }; RECT posRect = _p_instance->getPosRect();
POINTF container; HDC hDC = GetDC(hwnd);
if( SUCCEEDED(p_controlSite->TransformCoords(&extent,
&container, XFORMCOORDS_SIZE|XFORMCOORDS_HIMETRICTOCONTAINER)) )
{
posRect.right = ((LONG)container.x)+posRect.left;
posRect.bottom = ((LONG)container.y)+posRect.top;
}
p_controlSite->Release();
}
else {
// use HIMETRIC to display transform
HDC hDC = CreateDevDC(NULL);
posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left; posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left;
posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top; posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top;
DeleteDC(hDC); DeleteDC(hDC);
}
p_inPlaceSite->OnPosRectChange(&posRect); p_inPlaceSite->OnPosRectChange(&posRect);
}
p_inPlaceSite->Release(); p_inPlaceSite->Release();
} }
} }

View File

@ -40,7 +40,7 @@ STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistPropertyBag::InitNew(void) STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
{ {
return _p_instance->onInit(TRUE); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog) STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
@ -48,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->onInit(FALSE); HRESULT hr = _p_instance->onInit();
if( FAILED(hr) ) if( FAILED(hr) )
return hr; return hr;

View File

@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
if( NULL == pStg ) if( NULL == pStg )
return E_POINTER; return E_POINTER;
return _p_instance->onInit(TRUE); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) 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->onInit(TRUE); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)

View File

@ -37,7 +37,7 @@ STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStreamInit::InitNew(void) STDMETHODIMP VLCPersistStreamInit::InitNew(void)
{ {
return _p_instance->onInit(TRUE); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm) 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->onInit(TRUE); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty) STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)

View File

@ -34,6 +34,7 @@
#include "objectsafety.h" #include "objectsafety.h"
#include "vlccontrol.h" #include "vlccontrol.h"
#include "viewobject.h" #include "viewobject.h"
#include "dataobject.h"
#include "utils.h" #include "utils.h"
@ -510,7 +511,7 @@ static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
*lprPosRect = bounds; *lprPosRect = bounds;
}; };
HRESULT VLCPlugin::onInit(BOOL isNew) HRESULT VLCPlugin::onInit(void)
{ {
if( 0 == _i_vlc ) if( 0 == _i_vlc )
{ {
@ -549,21 +550,6 @@ HRESULT VLCPlugin::onInit(BOOL isNew)
_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;
@ -571,16 +557,20 @@ HRESULT VLCPlugin::onInit(BOOL isNew)
HRESULT VLCPlugin::onLoad(void) HRESULT VLCPlugin::onLoad(void)
{ {
/* if( _b_mute )
** object has fully initialized, VLC_VolumeMute(_i_vlc);
** try to activate in place if container is ready
*/
LPOLECLIENTSITE pActiveSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) ) if( NULL != _psz_src )
{ {
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL); // add default target to playlist
pActiveSite->Release(); char *cOptions[1];
int cOptionsCount = 0;
if( _b_loopmode )
{
cOptions[cOptionsCount++] = "loop";
}
VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
} }
return S_OK; return S_OK;
}; };
@ -694,24 +684,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
val.i_int = reinterpret_cast<int>(_videownd); val.i_int = reinterpret_cast<int>(_videownd);
VLC_VariableSet(_i_vlc, "drawable", val); VLC_VariableSet(_i_vlc, "drawable", val);
if( NULL != _psz_src ) if( _b_autostart & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
{
// add target to playlist
char *cOptions[1];
int cOptionsCount = 0;
if( _b_loopmode )
{
cOptions[cOptionsCount++] = "loop";
}
VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
if( _b_autostart )
{ {
VLC_Play(_i_vlc); VLC_Play(_i_vlc);
fireOnPlayEvent(); fireOnPlayEvent();
} }
}
return S_OK; return S_OK;
}; };
@ -749,6 +726,8 @@ BOOL VLCPlugin::hasFocus(void)
void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr) void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr)
{ {
if( getVisible() )
{
/* /*
** if VLC is playing, it may not display any VIDEO content ** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo ** hence, draw control logo
@ -793,6 +772,7 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr)
LineTo(hdc, bounds.left+width-1, bounds.top+height-1); LineTo(hdc, bounds.left+width-1, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top+height-1); LineTo(hdc, bounds.left, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top); LineTo(hdc, bounds.left, bounds.top);
}
}; };
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
@ -800,9 +780,16 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
RECT clipRect = *lprcClipRect; RECT clipRect = *lprcClipRect;
RECT posRect = *lprcPosRect; RECT posRect = *lprcPosRect;
/*
** tell container that previous area needs redrawing
*/
InvalidateRect(GetParent(_inplacewnd), &_posRect, TRUE);
/* /*
** record keeping of control geometry within container ** record keeping of control geometry within container
*/ */
_posRect = posRect; _posRect = posRect;
/* /*
@ -830,7 +817,6 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
posRect.bottom-posRect.top, posRect.bottom-posRect.top,
FALSE); FALSE);
/* /*
** force a full refresh of control content ** force a full refresh of control content
*/ */

View File

@ -84,7 +84,7 @@ 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 onInit(BOOL isNew); HRESULT onInit(void);
HRESULT onLoad(void); HRESULT onLoad(void);
HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite); HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
HRESULT onClose(DWORD dwSaveOption); HRESULT onClose(DWORD dwSaveOption);
@ -102,21 +102,15 @@ public:
int getVLCObject(void) { return _i_vlc; }; int getVLCObject(void) { return _i_vlc; };
// control properties // persistent control properties, may be overriden by HTML & javascript
void setSourceURL(const char *url) { _psz_src = strdup(url); }; void setSourceURL(const char *url) { _psz_src = strdup(url); };
void setAutoStart(BOOL autostart) { _b_autostart = autostart; }; void setAutoStart(BOOL autostart) { _b_autostart = autostart; };
void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; }; void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
void setMute(BOOL mute) { void setMute(BOOL mute) { _b_mute = mute; };
if( mute && _i_vlc )
{
VLC_VolumeMute(_i_vlc);
}
};
void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; }; void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };
void setVisible(BOOL fVisible); void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; }; BOOL getVisible(void) { return _b_visible; };
// container events // container events
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect); void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
void onPaint(HDC hdc, const RECT &bounds, const RECT &pr); void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
@ -167,6 +161,7 @@ private:
BOOL _b_autostart; BOOL _b_autostart;
BOOL _b_loopmode; BOOL _b_loopmode;
BOOL _b_visible; BOOL _b_visible;
BOOL _b_mute;
BOOL _b_sendevents; BOOL _b_sendevents;
int _i_vlc; int _i_vlc;

View File

@ -60,7 +60,6 @@ public:
STDMETHODIMP Reset(void); STDMETHODIMP Reset(void);
// cloning is implemented by subclasses and must use copy constructor // cloning is implemented by subclasses and must use copy constructor
//STDMETHODIMP Clone(VLCEnum<T> **); //STDMETHODIMP Clone(VLCEnum<T> **);
// cloning is implemented by subclasses and must use copy constructor
typedef void (*retainer)(T); typedef void (*retainer)(T);

View File

@ -32,8 +32,6 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue) LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
{ {
if( dwAspect & DVASPECT_CONTENT ) if( dwAspect & DVASPECT_CONTENT )
{
if( _p_instance->getVisible() )
{ {
RECT bounds; RECT bounds;
bounds.left = lprcBounds->left; bounds.left = lprcBounds->left;
@ -41,7 +39,6 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
bounds.right = lprcBounds->right; bounds.right = lprcBounds->right;
bounds.bottom = lprcBounds->bottom; bounds.bottom = lprcBounds->bottom;
_p_instance->onPaint(hdcDraw, bounds, bounds); _p_instance->onPaint(hdcDraw, bounds, bounds);
}
return S_OK; return S_OK;
} }
return E_NOTIMPL; return E_NOTIMPL;
@ -84,21 +81,22 @@ STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf, STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
LPADVISESINK pAdvSink) LPADVISESINK pAdvSink)
{ {
_dwAspect = dwAspect;
_advf = advf; if( NULL != pAdvSink )
pAdvSink->AddRef();
if( NULL != _pAdvSink ) if( NULL != _pAdvSink )
_pAdvSink->Release(); _pAdvSink->Release();
_dwAspect = dwAspect;
_advf = advf;
_pAdvSink = pAdvSink; _pAdvSink = pAdvSink;
if( NULL != pAdvSink )
{
pAdvSink->AddRef();
if( dwAspect & DVASPECT_CONTENT ) if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
{ {
pAdvSink->OnViewChange(DVASPECT_CONTENT, -1); _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
}
} }
return S_OK; return S_OK;
}; };

BIN
activex/vlc16x16.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B