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:
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;
}
}
else if( NULL == hwndParent )
+ {
return OLEOBJ_S_INVALIDHWND;
+ }
if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )
{
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{
- if( NULL != _p_clientsite )
- _p_clientsite->Release();
if( NULL != pClientSite )
{
VariantClear(&v);
}
}
+
+ if( NULL != _p_clientsite )
+ _p_clientsite->Release();
+
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
+
return S_OK;
};
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();
}
}
#include "objectsafety.h"
#include "vlccontrol.h"
#include "viewobject.h"
+#include "dataobject.h"
#include "utils.h"
*lprPosRect = bounds;
};
-HRESULT VLCPlugin::onInit(BOOL isNew)
+HRESULT VLCPlugin::onInit(void)
{
if( 0 == _i_vlc )
{
_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( _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;
};
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;
};
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)
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;
/*
posRect.bottom-posRect.top,
FALSE);
-
/*
** force a full refresh of control content
*/