1 /*****************************************************************************
2 * plugin.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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 "vlccontrol2.h"
37 #include "viewobject.h"
38 #include "dataobject.h"
39 #include "supporterrorinfo.h"
52 ////////////////////////////////////////////////////////////////////////
55 static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
56 VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
66 if( GetUpdateRect(hWnd, &pr, FALSE) )
69 GetClientRect(hWnd, &bounds);
70 BeginPaint(hWnd, &ps);
71 p_instance->onPaint(ps.hdc, bounds, pr);
77 return DefWindowProc(hWnd, uMsg, wParam, lParam);
81 VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid) :
82 _p_class_ref(p_class_ref),
83 _hinstance(hInstance),
85 _inplace_picture(NULL)
89 if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )
91 wClass.style = CS_NOCLOSE|CS_DBLCLKS;
92 wClass.lpfnWndProc = VLCInPlaceClassWndProc;
93 wClass.cbClsExtra = 0;
94 wClass.cbWndExtra = 0;
95 wClass.hInstance = hInstance;
97 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
98 wClass.hbrBackground = NULL;
99 wClass.lpszMenuName = NULL;
100 wClass.lpszClassName = getInPlaceWndClassName();
102 _inplace_wndclass_atom = RegisterClass(&wClass);
106 _inplace_wndclass_atom = 0;
109 HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
110 if( NULL != hbitmap )
114 pictDesc.cbSizeofstruct = sizeof(PICTDESC);
115 pictDesc.picType = PICTYPE_BITMAP;
116 pictDesc.bmp.hbitmap = hbitmap;
117 pictDesc.bmp.hpal = NULL;
119 if( FAILED(OleCreatePictureIndirect(&pictDesc, IID_IPicture, TRUE, reinterpret_cast<LPVOID*>(&_inplace_picture))) )
120 _inplace_picture = NULL;
125 VLCPluginClass::~VLCPluginClass()
127 if( 0 != _inplace_wndclass_atom )
128 UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
130 if( NULL != _inplace_picture )
131 _inplace_picture->Release();
134 STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)
139 if( (IID_IUnknown == riid)
140 || (IID_IClassFactory == riid) )
143 *ppv = reinterpret_cast<LPVOID>(this);
150 return E_NOINTERFACE;
153 STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)
155 return InterlockedIncrement(_p_class_ref);
158 STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)
160 ULONG refcount = InterlockedDecrement(_p_class_ref);
169 STDMETHODIMP VLCPluginClass::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
176 if( (NULL != pUnkOuter) && (IID_IUnknown != riid) ) {
177 return CLASS_E_NOAGGREGATION;
180 VLCPlugin *plugin = new VLCPlugin(this, pUnkOuter);
183 HRESULT hr = plugin->QueryInterface(riid, ppv);
184 // the following will destroy the object if QueryInterface() failed
188 return E_OUTOFMEMORY;
191 STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)
201 ////////////////////////////////////////////////////////////////////////
203 VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
213 vlcOleControl = new VLCOleControl(this);
214 vlcOleInPlaceObject = new VLCOleInPlaceObject(this);
215 vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);
216 vlcPersistStorage = new VLCPersistStorage(this);
217 vlcPersistStreamInit = new VLCPersistStreamInit(this);
218 vlcPersistPropertyBag = new VLCPersistPropertyBag(this);
219 vlcProvideClassInfo = new VLCProvideClassInfo(this);
220 vlcConnectionPointContainer = new VLCConnectionPointContainer(this);
221 vlcObjectSafety = new VLCObjectSafety(this);
222 vlcControl = new VLCControl(this);
223 vlcControl2 = new VLCControl2(this);
224 vlcViewObject = new VLCViewObject(this);
225 vlcDataObject = new VLCDataObject(this);
226 vlcOleObject = new VLCOleObject(this);
227 vlcSupportErrorInfo = new VLCSupportErrorInfo(this);
229 // configure controlling IUnknown interface for implemented interfaces
230 this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
233 _p_pict = p_class->getInPlacePict();
235 // make sure that persistable properties are initialized
239 VLCPlugin::~VLCPlugin()
241 delete vlcSupportErrorInfo;
243 delete vlcDataObject;
244 delete vlcViewObject;
247 delete vlcConnectionPointContainer;
248 delete vlcProvideClassInfo;
249 delete vlcPersistPropertyBag;
250 delete vlcPersistStreamInit;
251 delete vlcPersistStorage;
252 delete vlcOleInPlaceActiveObject;
253 delete vlcOleInPlaceObject;
254 delete vlcObjectSafety;
256 delete vlcOleControl;
260 SysFreeString(_bstr_mrl);
265 STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
270 if( IID_IUnknown == riid )
271 *ppv = reinterpret_cast<LPVOID>(this);
272 else if( IID_IOleObject == riid )
273 *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
274 else if( IID_IOleControl == riid )
275 *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
276 else if( IID_IOleWindow == riid )
277 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
278 else if( IID_IOleInPlaceObject == riid )
279 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
280 else if( IID_IOleInPlaceActiveObject == riid )
281 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
282 else if( IID_IPersist == riid )
283 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
284 else if( IID_IPersistStreamInit == riid )
285 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
286 else if( IID_IPersistStorage == riid )
287 *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
288 else if( IID_IPersistPropertyBag == riid )
289 *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
290 else if( IID_IProvideClassInfo == riid )
291 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
292 else if( IID_IProvideClassInfo2 == riid )
293 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
294 else if( IID_IConnectionPointContainer == riid )
295 *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
296 else if( IID_IObjectSafety == riid )
297 *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
298 else if( IID_IDispatch == riid )
299 *ppv = (CLSID_VLCPlugin2 == getClassID()) ?
300 reinterpret_cast<LPVOID>(vlcControl2) :
301 reinterpret_cast<LPVOID>(vlcControl);
302 else if( IID_IVLCControl == riid )
303 *ppv = reinterpret_cast<LPVOID>(vlcControl);
304 else if( IID_IVLCControl2 == riid )
305 *ppv = reinterpret_cast<LPVOID>(vlcControl2);
306 else if( IID_IViewObject == riid )
307 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
308 else if( IID_IViewObject2 == riid )
309 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
310 else if( IID_IDataObject == riid )
311 *ppv = reinterpret_cast<LPVOID>(vlcDataObject);
312 else if( IID_ISupportErrorInfo == riid )
313 *ppv = reinterpret_cast<LPVOID>(vlcSupportErrorInfo);
317 return E_NOINTERFACE;
319 ((LPUNKNOWN)*ppv)->AddRef();
323 STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)
325 return InterlockedIncrement((LONG *)&_i_ref);
328 STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
330 if( ! InterlockedDecrement((LONG *)&_i_ref) )
338 //////////////////////////////////////
340 HRESULT VLCPlugin::onInit(void)
342 if( NULL == _p_libvlc )
344 // initialize persistable properties
347 _bstr_baseurl = NULL;
353 // set default/preferred size (320x240) pixels in HIMETRIC
354 HDC hDC = CreateDevDC(NULL);
357 HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
362 return CO_E_ALREADYINITIALIZED;
365 HRESULT VLCPlugin::onLoad(void)
367 if( SysStringLen(_bstr_baseurl) == 0 )
370 ** try to retreive the base URL using the client site moniker, which for Internet Explorer
371 ** is the URL of the page the plugin is embedded into.
373 LPOLECLIENTSITE pClientSite;
374 if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
377 if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
379 LPMONIKER pContMoniker = NULL;
380 if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
381 OLEWHICHMK_CONTAINER, &pContMoniker)) )
384 if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &base_url)) )
387 ** check that the moniker name is a URL
389 if( UrlIsW(base_url, URLIS_URL) )
392 _bstr_baseurl = SysAllocString(base_url);
394 CoTaskMemFree(base_url);
404 HRESULT VLCPlugin::getVLCObject(int* i_vlc)
406 libvlc_instance_t *p_libvlc;
407 HRESULT result = getVLC(&p_libvlc);
408 if( SUCCEEDED(result) )
410 *i_vlc = libvlc_get_vlc_id(p_libvlc);
419 HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
421 extern HMODULE DllGetModule();
426 ** default initialization options
428 char *ppsz_argv[32] = { "vlc" };
432 DWORD i_type, i_data = MAX_PATH + 1;
433 char p_data[MAX_PATH + 1];
434 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
435 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
437 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
438 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
440 if( i_type == REG_SZ )
442 strcat( p_data, "\\plugins" );
443 //ppsz_argv[ppsz_argc++] = "--plugin-path";
444 //ppsz_argv[ppsz_argc++] = p_data;
447 RegCloseKey( h_key );
450 char p_path[MAX_PATH+1];
451 DWORD len = GetModuleFileNameA(DllGetModule(), p_path, sizeof(p_path));
455 ppsz_argv[0] = p_path;
458 // make sure plugin isn't affected with VLC single instance mode
459 ppsz_argv[ppsz_argc++] = "--no-one-instance";
461 /* common settings */
462 ppsz_argv[ppsz_argc++] = "-vv";
463 ppsz_argv[ppsz_argc++] = "--no-stats";
464 ppsz_argv[ppsz_argc++] = "--no-media-library";
465 ppsz_argv[ppsz_argc++] = "--intf";
466 ppsz_argv[ppsz_argc++] = "dummy";
468 // loop mode is a configuration option only
470 ppsz_argv[ppsz_argc++] = "--loop";
472 if( IsDebuggerPresent() )
475 ** VLC default threading mechanism is designed to be as compatible
476 ** with POSIX as possible. However when debugged on win32, threads
477 ** lose signals and eventually VLC get stuck during initialization.
478 ** threading support can be configured to be more debugging friendly
479 ** but it will be less compatible with POSIX.
480 ** This is done by initializing with the following options:
482 ppsz_argv[ppsz_argc++] = "--fast-mutex";
483 ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
486 _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL);
487 if( NULL == _p_libvlc )
493 // initial volume setting
494 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
497 libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
500 // initial playlist item
501 if( SysStringLen(_bstr_mrl) > 0 )
503 char *psz_mrl = NULL;
505 if( SysStringLen(_bstr_baseurl) > 0 )
507 DWORD len = INTERNET_MAX_URL_LENGTH;
508 LPOLESTR abs_url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*len);
509 if( NULL != abs_url )
512 ** if the MRL a relative URL, we should end up with an absolute URL
514 if( SUCCEEDED(UrlCombineW(_bstr_baseurl, _bstr_mrl, abs_url, &len,
515 URL_ESCAPE_UNSAFE|URL_PLUGGABLE_PROTOCOL)) )
517 psz_mrl = CStrFromBSTR(CP_UTF8, abs_url);
521 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
523 CoTaskMemFree(abs_url);
529 ** baseURL is empty, assume MRL is absolute
531 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
533 if( NULL != psz_mrl )
535 const char *options[1];
541 snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time);
542 options[i_options++] = timeBuffer;
544 // add default target to playlist
545 libvlc_playlist_add_extended(_p_libvlc, psz_mrl, NULL, i_options, options, NULL);
546 CoTaskMemFree(psz_mrl);
550 *pp_libvlc = _p_libvlc;
554 void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
556 vlcSupportErrorInfo->setErrorInfo( getClassID() == CLSID_VLCPlugin2 ?
557 OLESTR("VideoLAN.VLCPlugin.2") : OLESTR("VideoLAN.VLCPlugin.1"),
561 HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
566 case DISPID_AMBIENT_BACKCOLOR:
568 case DISPID_AMBIENT_DISPLAYNAME:
570 case DISPID_AMBIENT_FONT:
572 case DISPID_AMBIENT_FORECOLOR:
574 case DISPID_AMBIENT_LOCALEID:
576 case DISPID_AMBIENT_MESSAGEREFLECT:
578 case DISPID_AMBIENT_SCALEUNITS:
580 case DISPID_AMBIENT_TEXTALIGN:
582 case DISPID_AMBIENT_USERMODE:
585 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
587 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
590 case DISPID_AMBIENT_UIDEAD:
592 case DISPID_AMBIENT_SHOWGRABHANDLES:
594 case DISPID_AMBIENT_SHOWHATCHING:
596 case DISPID_AMBIENT_DISPLAYASDEFAULT:
598 case DISPID_AMBIENT_SUPPORTSMNEMONICS:
600 case DISPID_AMBIENT_AUTOCLIP:
602 case DISPID_AMBIENT_APPEARANCE:
604 case DISPID_AMBIENT_CODEPAGE:
607 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
609 setCodePage(V_I4(&v));
612 case DISPID_AMBIENT_PALETTE:
614 case DISPID_AMBIENT_CHARSET:
616 case DISPID_AMBIENT_RIGHTTOLEFT:
618 case DISPID_AMBIENT_TOPTOBOTTOM:
622 ** multiple property change, look up the ones we are interested in
626 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
628 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
632 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_CODEPAGE, v)) )
634 setCodePage(V_I4(&v));
641 HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
643 if( isInPlaceActive() )
645 onInPlaceDeactivate();
649 libvlc_instance_t* p_libvlc = _p_libvlc;
652 vlcDataObject->onClose();
654 libvlc_destroy(p_libvlc, NULL );
659 BOOL VLCPlugin::isInPlaceActive(void)
661 return (NULL != _inplacewnd);
664 HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
666 RECT clipRect = *lprcClipRect;
669 ** record keeping of control geometry within container
671 _posRect = *lprcPosRect;
674 ** Create a window for in place activated control.
675 ** the window geometry matches the control viewport
676 ** within container so that embedded video is always
677 ** properly displayed.
679 _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
680 "VLC Plugin In-Place Window",
681 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
684 lprcPosRect->right-lprcPosRect->left,
685 lprcPosRect->bottom-lprcPosRect->top,
688 _p_class->getHInstance(),
692 if( NULL == _inplacewnd )
695 SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
697 /* change cliprect coordinates system relative to window bounding rect */
698 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
700 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
701 SetWindowRgn(_inplacewnd, clipRgn, TRUE);
705 /* will run vlc if not done already */
706 libvlc_instance_t* p_libvlc;
707 HRESULT result = getVLC(&p_libvlc);
711 /* set internal video width and height */
712 libvlc_video_set_size(p_libvlc,
713 lprcPosRect->right-lprcPosRect->left,
714 lprcPosRect->bottom-lprcPosRect->top,
717 /* set internal video parent window */
718 libvlc_video_set_parent(p_libvlc,
719 reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
721 if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
723 libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
729 ShowWindow(_inplacewnd, SW_SHOW);
734 HRESULT VLCPlugin::onInPlaceDeactivate(void)
738 libvlc_playlist_stop(_p_libvlc, NULL);
742 DestroyWindow(_inplacewnd);
748 void VLCPlugin::setVisible(BOOL fVisible)
750 if( fVisible != _b_visible )
752 _b_visible = fVisible;
753 if( isInPlaceActive() )
755 ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
757 InvalidateRect(_inplacewnd, NULL, TRUE);
760 firePropChangedEvent(DISPID_Visible);
764 void VLCPlugin::setVolume(int volume)
768 else if( volume > 200 )
771 if( volume != _i_volume )
776 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
782 void VLCPlugin::setTime(int seconds)
787 if( seconds != _i_time )
789 setStartTime(_i_time);
792 libvlc_input_t *p_input = libvlc_playlist_get_input(_p_libvlc, NULL);
793 if( NULL != p_input )
795 libvlc_input_set_time(p_input, _i_time, NULL);
796 libvlc_input_free(p_input);
802 void VLCPlugin::setFocus(BOOL fFocus)
805 SetActiveWindow(_inplacewnd);
808 BOOL VLCPlugin::hasFocus(void)
810 return GetActiveWindow() == _inplacewnd;
813 void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
814 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
818 long width = lprcBounds->right-lprcBounds->left;
819 long height = lprcBounds->bottom-lprcBounds->top;
821 RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
822 FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
824 LPPICTURE pict = getPicture();
827 OLE_XSIZE_HIMETRIC picWidth;
828 OLE_YSIZE_HIMETRIC picHeight;
830 pict->get_Width(&picWidth);
831 pict->get_Height(&picHeight);
833 SIZEL picSize = { picWidth, picHeight };
835 if( NULL != hicTargetDev )
837 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
839 else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
841 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
842 DeleteDC(hicTargetDev);
845 if( picSize.cx > width-4 )
846 picSize.cx = width-4;
847 if( picSize.cy > height-4 )
848 picSize.cy = height-4;
850 LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
851 LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
853 if( NULL != lprcWBounds )
855 RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
856 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
857 0L, picHeight, picWidth, -picHeight, &wBounds);
860 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
861 0L, picHeight, picWidth, -picHeight, NULL);
866 SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
868 MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
869 LineTo(hdcDraw, bounds.left+width-1, bounds.top);
870 LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
871 LineTo(hdcDraw, bounds.left, bounds.top+height-1);
872 LineTo(hdcDraw, bounds.left, bounds.top);
876 void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
880 /** if VLC is playing, it may not display any VIDEO content
881 ** hence, draw control logo*/
882 HDC hdcDraw = CreateCompatibleDC(hdc);
883 if( NULL != hdcDraw )
885 SIZEL size = getExtent();
886 DPFromHimetric(hdc, (LPPOINT)&size, 1);
887 RECTL posRect = { 0, 0, size.cx, size.cy };
889 int width = bounds.right-bounds.left;
890 int height = bounds.bottom-bounds.top;
892 HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
893 if( NULL != hBitmap )
895 HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
897 if( (size.cx != width) || (size.cy != height) )
899 // needs to scale canvas
900 SetMapMode(hdcDraw, MM_ANISOTROPIC);
901 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
902 SetViewportExtEx(hdcDraw, width, height, NULL);
905 onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
907 SetMapMode(hdcDraw, MM_TEXT);
908 BitBlt(hdc, bounds.left, bounds.top,
913 SelectObject(hdcDraw, oldBmp);
914 DeleteObject(hBitmap);
921 void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
923 RECT clipRect = *lprcClipRect;
925 //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
928 ** record keeping of control geometry within container
930 _posRect = *lprcPosRect;
933 ** change in-place window geometry to match clipping region
935 SetWindowPos(_inplacewnd, NULL,
938 lprcPosRect->right-lprcPosRect->left,
939 lprcPosRect->bottom-lprcPosRect->top,
945 /* change cliprect coordinates system relative to window bounding rect */
946 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
947 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
948 SetWindowRgn(_inplacewnd, clipRgn, FALSE);
950 //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
953 libvlc_video_set_size(_p_libvlc,
954 lprcPosRect->right-lprcPosRect->left,
955 lprcPosRect->bottom-lprcPosRect->top,
960 void VLCPlugin::freezeEvents(BOOL freeze)
962 vlcConnectionPointContainer->freezeEvents(freeze);
965 void VLCPlugin::firePropChangedEvent(DISPID dispid)
967 vlcConnectionPointContainer->firePropChangedEvent(dispid);
970 void VLCPlugin::fireOnPlayEvent(void)
972 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
973 vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs);
976 void VLCPlugin::fireOnPauseEvent(void)
978 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
979 vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs);
982 void VLCPlugin::fireOnStopEvent(void)
984 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
985 vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);