Commit da4dc63b authored by Damien Fouilleul's avatar Damien Fouilleul

all: clean-up, bug fixes so that plugin is now working correctly with Visual...

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
parent da5c4157
......@@ -52,6 +52,7 @@ DIST_misc = \
axvlc.idl \
axvlc.tlb \
inplace.bmp \
vlc16x16.bmp \
test.html \
$(NULL)
......
......@@ -8,6 +8,7 @@
#define STRINGIFY( z ) UGLY_KLUDGE( z )
#define UGLY_KLUDGE( z ) #z
1 BITMAP "vlc16x16.bmp"
1 VERSIONINFO
FILETYPE 1
FILEOS 4
......
......@@ -186,6 +186,14 @@ STDAPI DllRegisterServer(VOID)
hSubKey = keyCreate(hClassKey, TEXT("Control"));
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
// LocalServer32 key value
hSubKey = keyCreate(hClassKey, TEXT("LocalServer32"));
......
......@@ -56,9 +56,6 @@ STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect)
{
if( 0 != lIndex )
return DV_E_LINDEX;
switch( iVerb )
{
case OLEIVERB_PRIMARY:
......@@ -104,7 +101,9 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
if( S_OK != p_inPlaceSite->CanInPlaceActivate() )
{
return OLEOBJ_S_CANNOT_DOVERB_NOW;
}
LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
......@@ -128,7 +127,9 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
}
}
else if( NULL == hwndParent )
{
return OLEOBJ_S_INVALIDHWND;
}
if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )
{
......@@ -293,8 +294,6 @@ STDMETHODIMP VLCOleObject::IsUpToDate(void)
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{
if( NULL != _p_clientsite )
_p_clientsite->Release();
if( NULL != pClientSite )
{
......@@ -312,8 +311,13 @@ STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
VariantClear(&v);
}
}
if( NULL != _p_clientsite )
_p_clientsite->Release();
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
return S_OK;
};
......@@ -337,30 +341,18 @@ STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel)
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
LPOLECONTROLSITE p_controlSite;
RECT posRect = _p_instance->getPosRect();
HWND hwnd;
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleControlSite, (void**)&p_controlSite)) )
if( SUCCEEDED(p_inPlaceSite->GetWindow(&hwnd)) )
{
// use HIMETRIC to container transform
POINTL extent = { pSizel->cx, pSizel->cy };
POINTF container;
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);
// use HIMETRIC to pixel transform
RECT posRect = _p_instance->getPosRect();
HDC hDC = GetDC(hwnd);
posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left;
posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top;
DeleteDC(hDC);
p_inPlaceSite->OnPosRectChange(&posRect);
}
p_inPlaceSite->OnPosRectChange(&posRect);
p_inPlaceSite->Release();
}
}
......
......@@ -40,7 +40,7 @@ STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
{
return _p_instance->onInit(TRUE);
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
......@@ -48,7 +48,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
if( NULL == pPropBag )
return E_POINTER;
HRESULT hr = _p_instance->onInit(FALSE);
HRESULT hr = _p_instance->onInit();
if( FAILED(hr) )
return hr;
......
......@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInit(TRUE);
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
......@@ -53,7 +53,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInit(TRUE);
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
......
......@@ -37,7 +37,7 @@ STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStreamInit::InitNew(void)
{
return _p_instance->onInit(TRUE);
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
......@@ -45,7 +45,7 @@ STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
if( NULL == pStm )
return E_POINTER;
return _p_instance->onInit(TRUE);
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)
......
......@@ -34,6 +34,7 @@
#include "objectsafety.h"
#include "vlccontrol.h"
#include "viewobject.h"
#include "dataobject.h"
#include "utils.h"
......@@ -510,7 +511,7 @@ static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
*lprPosRect = bounds;
};
HRESULT VLCPlugin::onInit(BOOL isNew)
HRESULT VLCPlugin::onInit(void)
{
if( 0 == _i_vlc )
{
......@@ -549,21 +550,6 @@ HRESULT VLCPlugin::onInit(BOOL isNew)
_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;
......@@ -571,16 +557,20 @@ HRESULT VLCPlugin::onInit(BOOL isNew)
HRESULT VLCPlugin::onLoad(void)
{
/*
** object has fully initialized,
** try to activate in place if container is ready
*/
LPOLECLIENTSITE pActiveSite;
if( _b_mute )
VLC_VolumeMute(_i_vlc);
if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) )
if( NULL != _psz_src )
{
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL);
pActiveSite->Release();
// add default 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);
}
return S_OK;
};
......@@ -694,23 +684,10 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
val.i_int = reinterpret_cast<int>(_videownd);
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);
fireOnPlayEvent();
}
VLC_Play(_i_vlc);
fireOnPlayEvent();
}
return S_OK;
};
......@@ -749,50 +726,53 @@ BOOL VLCPlugin::hasFocus(void)
void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr)
{
/*
** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo
*/
int width = bounds.right-bounds.left;
int height = bounds.bottom-bounds.top;
HBITMAP pict = _p_class->getInPlacePict();
if( NULL != pict )
if( getVisible() )
{
HDC hdcPict = CreateCompatibleDC(hdc);
if( NULL != hdcPict )
/*
** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo
*/
int width = bounds.right-bounds.left;
int height = bounds.bottom-bounds.top;
HBITMAP pict = _p_class->getInPlacePict();
if( NULL != pict )
{
BITMAP bm;
if( GetObject(pict, sizeof(BITMAPINFO), &bm) )
HDC hdcPict = CreateCompatibleDC(hdc);
if( NULL != hdcPict )
{
int dstWidth = bm.bmWidth;
if( dstWidth > width-4 )
dstWidth = width-4;
int dstHeight = bm.bmHeight;
if( dstHeight > height-4 )
dstHeight = height-4;
int dstX = bounds.left+(width-dstWidth)/2;
int dstY = bounds.top+(height-dstHeight)/2;
SelectObject(hdcPict, pict);
StretchBlt(hdc, dstX, dstY, dstWidth, dstHeight,
hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
DeleteDC(hdcPict);
ExcludeClipRect(hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY);
BITMAP bm;
if( GetObject(pict, sizeof(BITMAPINFO), &bm) )
{
int dstWidth = bm.bmWidth;
if( dstWidth > width-4 )
dstWidth = width-4;
int dstHeight = bm.bmHeight;
if( dstHeight > height-4 )
dstHeight = height-4;
int dstX = bounds.left+(width-dstWidth)/2;
int dstY = bounds.top+(height-dstHeight)/2;
SelectObject(hdcPict, pict);
StretchBlt(hdc, dstX, dstY, dstWidth, dstHeight,
hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
DeleteDC(hdcPict);
ExcludeClipRect(hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY);
}
}
}
}
FillRect(hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH));
SelectObject(hdc, GetStockObject(BLACK_BRUSH));
FillRect(hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH));
SelectObject(hdc, GetStockObject(BLACK_BRUSH));
MoveToEx(hdc, bounds.left, bounds.top, NULL);
LineTo(hdc, bounds.left+width-1, bounds.top);
LineTo(hdc, bounds.left+width-1, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top);
MoveToEx(hdc, bounds.left, bounds.top, NULL);
LineTo(hdc, bounds.left+width-1, bounds.top);
LineTo(hdc, bounds.left+width-1, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top+height-1);
LineTo(hdc, bounds.left, bounds.top);
}
};
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
......@@ -800,9 +780,16 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
RECT clipRect = *lprcClipRect;
RECT posRect = *lprcPosRect;
/*
** tell container that previous area needs redrawing
*/
InvalidateRect(GetParent(_inplacewnd), &_posRect, TRUE);
/*
** record keeping of control geometry within container
*/
*/
_posRect = posRect;
/*
......@@ -830,7 +817,6 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
posRect.bottom-posRect.top,
FALSE);
/*
** force a full refresh of control content
*/
......
......@@ -84,7 +84,7 @@ public:
REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
HRESULT onInit(BOOL isNew);
HRESULT onInit(void);
HRESULT onLoad(void);
HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
HRESULT onClose(DWORD dwSaveOption);
......@@ -102,20 +102,14 @@ public:
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 setAutoStart(BOOL autostart) { _b_autostart = autostart; };
void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
void setMute(BOOL mute) {
if( mute && _i_vlc )
{
VLC_VolumeMute(_i_vlc);
}
};
void setMute(BOOL mute) { _b_mute = mute; };
void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
// container events
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
......@@ -167,6 +161,7 @@ private:
BOOL _b_autostart;
BOOL _b_loopmode;
BOOL _b_visible;
BOOL _b_mute;
BOOL _b_sendevents;
int _i_vlc;
......
......@@ -60,7 +60,6 @@ public:
STDMETHODIMP Reset(void);
// cloning is implemented by subclasses and must use copy constructor
//STDMETHODIMP Clone(VLCEnum<T> **);
// cloning is implemented by subclasses and must use copy constructor
typedef void (*retainer)(T);
......
......@@ -33,15 +33,12 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
{
if( dwAspect & DVASPECT_CONTENT )
{
if( _p_instance->getVisible() )
{
RECT bounds;
bounds.left = lprcBounds->left;
bounds.top = lprcBounds->top;
bounds.right = lprcBounds->right;
bounds.bottom = lprcBounds->bottom;
_p_instance->onPaint(hdcDraw, bounds, bounds);
}
RECT bounds;
bounds.left = lprcBounds->left;
bounds.top = lprcBounds->top;
bounds.right = lprcBounds->right;
bounds.bottom = lprcBounds->bottom;
_p_instance->onPaint(hdcDraw, bounds, bounds);
return S_OK;
}
return E_NOTIMPL;
......@@ -84,21 +81,22 @@ STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
LPADVISESINK pAdvSink)
{
_dwAspect = dwAspect;
_advf = advf;
if( NULL != pAdvSink )
pAdvSink->AddRef();
if( NULL != _pAdvSink )
_pAdvSink->Release();
_dwAspect = dwAspect;
_advf = advf;
_pAdvSink = pAdvSink;
if( NULL != pAdvSink )
{
pAdvSink->AddRef();
if( dwAspect & DVASPECT_CONTENT )
{
pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
}
if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
{
_pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
}
return S_OK;
};
......
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