1 /*****************************************************************************
2 * plugin.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
25 #include "oleobject.h"
26 #include "olecontrol.h"
27 #include "oleinplaceobject.h"
28 #include "oleinplaceactiveobject.h"
29 #include "persistpropbag.h"
30 #include "persiststreaminit.h"
31 #include "persiststorage.h"
32 #include "provideclassinfo.h"
33 #include "connectioncontainer.h"
34 #include "objectsafety.h"
35 #include "vlccontrol.h"
36 #include "viewobject.h"
37 #include "dataobject.h"
50 ////////////////////////////////////////////////////////////////////////
53 // {E23FE9C6-778E-49d4-B537-38FCDE4887D8}
54 //const GUID CLSID_VLCPlugin =
55 // { 0xe23fe9c6, 0x778e, 0x49d4, { 0xb5, 0x37, 0x38, 0xfc, 0xde, 0x48, 0x87, 0xd8 } };
57 static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
65 if( GetUpdateRect(hWnd, NULL, FALSE) )
67 BeginPaint(hWnd, &ps);
73 return DefWindowProc(hWnd, uMsg, wParam, lParam);
77 static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
78 VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
88 if( GetUpdateRect(hWnd, &pr, FALSE) )
91 GetClientRect(hWnd, &bounds);
92 BeginPaint(hWnd, &ps);
93 p_instance->onPaint(ps.hdc, bounds, pr);
99 return DefWindowProc(hWnd, uMsg, wParam, lParam);
103 VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :
104 _p_class_ref(p_class_ref),
105 _hinstance(hInstance),
106 _inplace_picture(NULL)
110 if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )
112 wClass.style = CS_NOCLOSE|CS_DBLCLKS;
113 wClass.lpfnWndProc = VLCInPlaceClassWndProc;
114 wClass.cbClsExtra = 0;
115 wClass.cbWndExtra = 0;
116 wClass.hInstance = hInstance;
118 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
119 wClass.hbrBackground = NULL;
120 wClass.lpszMenuName = NULL;
121 wClass.lpszClassName = getInPlaceWndClassName();
123 _inplace_wndclass_atom = RegisterClass(&wClass);
127 _inplace_wndclass_atom = 0;
130 if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )
132 wClass.style = CS_NOCLOSE;
133 wClass.lpfnWndProc = VLCVideoClassWndProc;
134 wClass.cbClsExtra = 0;
135 wClass.cbWndExtra = 0;
136 wClass.hInstance = hInstance;
138 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
139 wClass.hbrBackground = NULL;
140 wClass.lpszMenuName = NULL;
141 wClass.lpszClassName = getVideoWndClassName();
143 _video_wndclass_atom = RegisterClass(&wClass);
147 _video_wndclass_atom = 0;
150 HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
151 if( NULL != hbitmap )
155 pictDesc.cbSizeofstruct = sizeof(PICTDESC);
156 pictDesc.picType = PICTYPE_BITMAP;
157 pictDesc.bmp.hbitmap = hbitmap;
158 pictDesc.bmp.hpal = NULL;
160 if( FAILED(OleCreatePictureIndirect(&pictDesc, IID_IPicture, TRUE, reinterpret_cast<LPVOID*>(&_inplace_picture))) )
161 _inplace_picture = NULL;
166 VLCPluginClass::~VLCPluginClass()
168 if( 0 != _inplace_wndclass_atom )
169 UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
171 if( 0 != _video_wndclass_atom )
172 UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance);
174 if( NULL != _inplace_picture )
175 _inplace_picture->Release();
178 STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)
183 if( (IID_IUnknown == riid) || (IID_IClassFactory == riid) )
186 *ppv = reinterpret_cast<LPVOID>(this);
193 return E_NOINTERFACE;
196 STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)
198 return InterlockedIncrement(_p_class_ref);
201 STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)
203 ULONG refcount = InterlockedDecrement(_p_class_ref);
212 STDMETHODIMP VLCPluginClass::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
219 if( (NULL != pUnkOuter) && (IID_IUnknown != riid) ) {
220 return CLASS_E_NOAGGREGATION;
223 VLCPlugin *plugin = new VLCPlugin(this, pUnkOuter);
226 HRESULT hr = plugin->QueryInterface(riid, ppv);
230 return E_OUTOFMEMORY;
233 STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)
243 ////////////////////////////////////////////////////////////////////////
245 VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
260 vlcOleControl = new VLCOleControl(this);
261 vlcOleInPlaceObject = new VLCOleInPlaceObject(this);
262 vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);
263 vlcPersistStorage = new VLCPersistStorage(this);
264 vlcPersistStreamInit = new VLCPersistStreamInit(this);
265 vlcPersistPropertyBag = new VLCPersistPropertyBag(this);
266 vlcProvideClassInfo = new VLCProvideClassInfo(this);
267 vlcConnectionPointContainer = new VLCConnectionPointContainer(this);
268 vlcObjectSafety = new VLCObjectSafety(this);
269 vlcControl = new VLCControl(this);
270 vlcViewObject = new VLCViewObject(this);
271 vlcDataObject = new VLCDataObject(this);
272 vlcOleObject = new VLCOleObject(this);
274 // configure controlling IUnknown interface for implemented interfaces
275 this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
278 _p_pict = p_class->getInPlacePict();
280 // set default/preferred size (320x240) pixels in HIMETRIC
281 HDC hDC = CreateDevDC(NULL);
284 HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
288 VLCPlugin::~VLCPlugin()
291 delete vlcDataObject;
292 delete vlcViewObject;
294 delete vlcConnectionPointContainer;
295 delete vlcProvideClassInfo;
296 delete vlcPersistPropertyBag;
297 delete vlcPersistStreamInit;
298 delete vlcPersistStorage;
299 delete vlcOleInPlaceActiveObject;
300 delete vlcOleInPlaceObject;
301 delete vlcObjectSafety;
303 delete vlcOleControl;
307 SysFreeString(_bstr_mrl);
312 STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
317 if( IID_IUnknown == riid )
318 *ppv = reinterpret_cast<LPVOID>(this);
319 else if( IID_IOleObject == riid )
320 *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
321 else if( IID_IOleControl == riid )
322 *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
323 else if( IID_IOleWindow == riid )
324 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
325 else if( IID_IOleInPlaceObject == riid )
326 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
327 else if( IID_IOleInPlaceActiveObject == riid )
328 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
329 else if( IID_IPersist == riid )
330 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
331 else if( IID_IPersistStreamInit == riid )
332 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
333 else if( IID_IPersistStorage == riid )
334 *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
335 else if( IID_IPersistPropertyBag == riid )
336 *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
337 else if( IID_IProvideClassInfo == riid )
338 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
339 else if( IID_IProvideClassInfo2 == riid )
340 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
341 else if( IID_IConnectionPointContainer == riid )
342 *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
343 else if( IID_IObjectSafety == riid )
344 *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
345 else if( IID_IDispatch == riid )
346 *ppv = reinterpret_cast<LPVOID>(vlcControl);
347 else if( IID_IVLCControl == riid )
348 *ppv = reinterpret_cast<LPVOID>(vlcControl);
349 else if( IID_IViewObject == riid )
350 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
351 else if( IID_IViewObject2 == riid )
352 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
353 else if( IID_IDataObject == riid )
354 *ppv = reinterpret_cast<LPVOID>(vlcDataObject);
358 return E_NOINTERFACE;
360 ((LPUNKNOWN)*ppv)->AddRef();
364 STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)
366 return InterlockedIncrement((LONG *)&_i_ref);
369 STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
371 if( ! InterlockedDecrement((LONG *)&_i_ref) )
379 //////////////////////////////////////
382 ** we use a window to represent plugin viewport,
383 ** whose geometry is limited by the clipping rectangle
384 ** all drawing within this window must follow must
385 ** follow coordinates system described in lprPosRect
388 static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
391 bounds.right = lprPosRect->right-lprPosRect->left;
393 if( lprClipRect->left <= lprPosRect->left )
395 // left side is not clipped out
398 if( lprClipRect->right >= lprPosRect->right )
400 // right side is not clipped out, no change
402 else if( lprClipRect->right >= lprPosRect->left )
404 // right side is clipped out
405 lprPosRect->right = lprClipRect->right;
409 // outside of clipping rectange, not visible
410 lprPosRect->right = lprPosRect->left;
415 // left side is clipped out
416 bounds.left = lprPosRect->left-lprClipRect->left;
417 bounds.right += bounds.left;
419 lprPosRect->left = lprClipRect->left;
420 if( lprClipRect->right >= lprPosRect->right )
422 // right side is not clipped out
426 // right side is clipped out
427 lprPosRect->right = lprClipRect->right;
431 bounds.bottom = lprPosRect->bottom-lprPosRect->top;
433 if( lprClipRect->top <= lprPosRect->top )
435 // top side is not clipped out
438 if( lprClipRect->bottom >= lprPosRect->bottom )
440 // bottom side is not clipped out, no change
442 else if( lprClipRect->bottom >= lprPosRect->top )
444 // bottom side is clipped out
445 lprPosRect->bottom = lprClipRect->bottom;
449 // outside of clipping rectange, not visible
450 lprPosRect->right = lprPosRect->left;
455 bounds.top = lprPosRect->top-lprClipRect->top;
456 bounds.bottom += bounds.top;
458 lprPosRect->top = lprClipRect->top;
459 if( lprClipRect->bottom >= lprPosRect->bottom )
461 // bottom side is not clipped out
465 // bottom side is clipped out
466 lprPosRect->bottom = lprClipRect->bottom;
469 *lprClipRect = *lprPosRect;
470 *lprPosRect = bounds;
473 HRESULT VLCPlugin::onInit(void)
477 _i_vlc = VLC_Create();
485 ** default initialization options
487 char *ppsz_argv[10] = { "vlc", "-vv" };
491 DWORD i_type, i_data = MAX_PATH + 1;
492 char p_data[MAX_PATH + 1];
493 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
494 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
496 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
497 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
499 if( i_type == REG_SZ )
501 strcat( p_data, "\\vlc" );
502 ppsz_argv[0] = p_data;
505 RegCloseKey( h_key );
509 ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
512 if( IsDebuggerPresent() )
515 ** VLC default threading mechanism is designed to be as compatible
516 ** with POSIX as possible, however when debugged on win32, threads
517 ** lose signals and eventually VLC get stuck during initialization.
518 ** threading support can be configured to be more debugging friendly
519 ** but it will be less compatible with POSIX.
520 ** This is done by initializing with the following options
522 ppsz_argv[ppsz_argc++] = "--fast-mutex";
523 ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
526 if( VLC_Init(_i_vlc, ppsz_argc, ppsz_argv) )
534 return CO_E_ALREADYINITIALIZED;
537 HRESULT VLCPlugin::onLoad(void)
540 VLC_VolumeMute(_i_vlc);
542 if( SysStringLen(_bstr_mrl) > 0 )
545 ** try to combine MRL with client site moniker, which for Internet Explorer
546 ** is the URL of the page the plugin is embedded into. Hence, if the MRL
547 ** is a relative URL, we should end up with an absolute URL
549 IOleClientSite *pClientSite;
550 if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
553 if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
555 LPMONIKER pContMoniker = NULL;
556 if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
557 OLEWHICHMK_CONTAINER, &pContMoniker)) )
560 if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &name)) )
562 if( UrlIsW(name, URLIS_URL) )
564 LPOLESTR url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*INTERNET_MAX_URL_LENGTH);
567 DWORD len = INTERNET_MAX_URL_LENGTH;
568 if( SUCCEEDED(UrlCombineW(name, _bstr_mrl, url, &len,
569 URL_ESCAPE_UNSAFE)) )
571 SysFreeString(_bstr_mrl);
572 _bstr_mrl = SysAllocStringLen(url, len);
579 pContMoniker->Release();
583 pClientSite->Release();
586 char *psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
587 if( NULL != psz_mrl )
589 // add default target to playlist
591 int cOptionsCount = 0;
595 cOptions[cOptionsCount++] = "loop";
597 VLC_AddTarget(_i_vlc, psz_mrl, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
598 CoTaskMemFree(psz_mrl);
605 HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
610 case DISPID_AMBIENT_BACKCOLOR:
612 case DISPID_AMBIENT_DISPLAYNAME:
614 case DISPID_AMBIENT_FONT:
616 case DISPID_AMBIENT_FORECOLOR:
618 case DISPID_AMBIENT_LOCALEID:
620 case DISPID_AMBIENT_MESSAGEREFLECT:
622 case DISPID_AMBIENT_SCALEUNITS:
624 case DISPID_AMBIENT_TEXTALIGN:
626 case DISPID_AMBIENT_USERMODE:
629 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
631 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
635 case DISPID_AMBIENT_UIDEAD:
637 case DISPID_AMBIENT_SHOWGRABHANDLES:
639 case DISPID_AMBIENT_SHOWHATCHING:
641 case DISPID_AMBIENT_DISPLAYASDEFAULT:
643 case DISPID_AMBIENT_SUPPORTSMNEMONICS:
645 case DISPID_AMBIENT_AUTOCLIP:
647 case DISPID_AMBIENT_APPEARANCE:
649 case DISPID_AMBIENT_CODEPAGE:
652 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
654 setCodePage(V_I4(&v));
657 case DISPID_AMBIENT_PALETTE:
659 case DISPID_AMBIENT_CHARSET:
661 case DISPID_AMBIENT_RIGHTTOLEFT:
663 case DISPID_AMBIENT_TOPTOBOTTOM:
668 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
670 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
675 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_CODEPAGE, v)) )
677 setCodePage(V_I4(&v));
685 HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
692 if( isInPlaceActive() )
694 onInPlaceDeactivate();
696 vlcDataObject->onClose();
704 BOOL VLCPlugin::isInPlaceActive(void)
706 return (NULL != _inplacewnd);
709 HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
711 RECT posRect = *lprcPosRect;
712 RECT clipRect = *lprcClipRect;
715 ** record keeping of control geometry within container
720 ** convert posRect & clipRect to match control viewport coordinates
722 getViewportCoords(&posRect, &clipRect);
725 ** Create a window for in place activated control.
726 ** the window geometry represents the control viewport
727 ** so that embedded video is always properly clipped.
729 _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
730 "VLC Plugin In-Place Window",
731 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
734 clipRect.right-clipRect.left,
735 clipRect.bottom-clipRect.top,
738 _p_class->getHInstance(),
742 if( NULL == _inplacewnd )
745 SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
748 ** VLC embedded video geometry automatically matches parent window.
749 ** hence create a child window so that video position and size
750 ** is always correct relative to the viewport bounds
752 _videownd = CreateWindow(_p_class->getVideoWndClassName(),
753 "VLC Plugin Video Window",
754 WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
757 posRect.right-posRect.left,
758 posRect.bottom-posRect.top,
761 _p_class->getHInstance(),
765 if( NULL == _videownd )
767 DestroyWindow(_inplacewnd);
771 SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
774 ShowWindow(_inplacewnd, SW_SHOWNORMAL);
776 /* horrible cast there */
778 val.i_int = reinterpret_cast<int>(_videownd);
779 VLC_VariableSet(_i_vlc, "drawable", val);
780 val.i_int = posRect.right-posRect.left;
781 VLC_VariableSet(_i_vlc, "width", val);
782 val.i_int = posRect.bottom-posRect.top;
783 VLC_VariableSet(_i_vlc, "height", val);
785 if( _b_usermode && _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
793 HRESULT VLCPlugin::onInPlaceDeactivate(void)
798 DestroyWindow(_videownd);
800 DestroyWindow(_inplacewnd);
806 void VLCPlugin::setVisible(BOOL fVisible)
808 _b_visible = fVisible;
809 if( isInPlaceActive() )
810 ShowWindow(_inplacewnd, fVisible ? SW_SHOWNORMAL : SW_HIDE);
811 firePropChangedEvent(DISPID_Visible);
814 void VLCPlugin::setFocus(BOOL fFocus)
817 SetActiveWindow(_inplacewnd);
820 BOOL VLCPlugin::hasFocus(void)
822 return GetActiveWindow() == _inplacewnd;
825 void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
826 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
830 long width = lprcBounds->right-lprcBounds->left;
831 long height = lprcBounds->bottom-lprcBounds->top;
833 RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
834 FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
836 LPPICTURE pict = getPicture();
839 OLE_XSIZE_HIMETRIC picWidth;
840 OLE_YSIZE_HIMETRIC picHeight;
842 pict->get_Width(&picWidth);
843 pict->get_Height(&picHeight);
845 SIZEL picSize = { picWidth, picHeight };
847 if( NULL != hicTargetDev )
849 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
851 else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
853 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
854 DeleteDC(hicTargetDev);
857 if( picSize.cx > width-4 )
858 picSize.cx = width-4;
859 if( picSize.cy > height-4 )
860 picSize.cy = height-4;
862 LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
863 LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
865 if( NULL != lprcWBounds )
867 RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
868 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
869 0L, picHeight, picWidth, -picHeight, &wBounds);
872 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
873 0L, picHeight, picWidth, -picHeight, NULL);
878 SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
880 MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
881 LineTo(hdcDraw, bounds.left+width-1, bounds.top);
882 LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
883 LineTo(hdcDraw, bounds.left, bounds.top+height-1);
884 LineTo(hdcDraw, bounds.left, bounds.top);
888 void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
892 /** if VLC is playing, it may not display any VIDEO content
893 ** hence, draw control logo*/
894 HDC hdcDraw = CreateCompatibleDC(hdc);
895 if( NULL != hdcDraw )
897 SIZEL size = getExtent();
898 DPFromHimetric(hdc, (LPPOINT)&size, 1);
899 RECTL posRect = { 0, 0, size.cx, size.cy };
901 int width = bounds.right-bounds.left;
902 int height = bounds.bottom-bounds.top;
904 HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
905 if( NULL != hBitmap )
907 HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
909 if( (size.cx != width) || (size.cx != height) )
911 // needs to scale canvas
912 SetMapMode(hdcDraw, MM_ANISOTROPIC);
913 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
914 SetViewportExtEx(hdcDraw, width, height, NULL);
917 onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
919 SetMapMode(hdcDraw, MM_TEXT);
920 BitBlt(hdc, bounds.left, bounds.top,
925 SelectObject(hdcDraw, oldBmp);
926 DeleteObject(hBitmap);
933 void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
935 RECT clipRect = *lprcClipRect;
936 RECT posRect = *lprcPosRect;
938 //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
941 ** record keeping of control geometry within container
946 ** convert posRect & clipRect to match control viewport coordinates
948 getViewportCoords(&posRect, &clipRect);
951 ** change in-place window geometry to match clipping region
953 SetWindowPos(_inplacewnd, NULL,
956 clipRect.right-clipRect.left,
957 clipRect.bottom-clipRect.top,
964 ** change video window geometry to match object bounds within clipping region
966 SetWindowPos(_videownd, NULL,
969 posRect.right-posRect.left,
970 posRect.bottom-posRect.top,
976 //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
978 val.i_int = posRect.right-posRect.left;
979 VLC_VariableSet(_i_vlc, "width", val);
980 val.i_int = posRect.bottom-posRect.top;
981 VLC_VariableSet(_i_vlc, "height", val);
984 void VLCPlugin::freezeEvents(BOOL freeze)
986 vlcConnectionPointContainer->freezeEvents(freeze);
989 void VLCPlugin::firePropChangedEvent(DISPID dispid)
991 vlcConnectionPointContainer->firePropChangedEvent(dispid);
994 void VLCPlugin::fireOnPlayEvent(void)
996 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
997 vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs);
1000 void VLCPlugin::fireOnPauseEvent(void)
1002 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
1003 vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs);
1006 void VLCPlugin::fireOnStopEvent(void)
1008 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
1009 vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);