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"
51 ////////////////////////////////////////////////////////////////////////
54 static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
55 VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
65 if( GetUpdateRect(hWnd, &pr, FALSE) )
68 GetClientRect(hWnd, &bounds);
69 BeginPaint(hWnd, &ps);
70 p_instance->onPaint(ps.hdc, bounds, pr);
76 return DefWindowProc(hWnd, uMsg, wParam, lParam);
80 VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid) :
81 _p_class_ref(p_class_ref),
82 _hinstance(hInstance),
84 _inplace_picture(NULL)
88 if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )
90 wClass.style = CS_NOCLOSE|CS_DBLCLKS;
91 wClass.lpfnWndProc = VLCInPlaceClassWndProc;
92 wClass.cbClsExtra = 0;
93 wClass.cbWndExtra = 0;
94 wClass.hInstance = hInstance;
96 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
97 wClass.hbrBackground = NULL;
98 wClass.lpszMenuName = NULL;
99 wClass.lpszClassName = getInPlaceWndClassName();
101 _inplace_wndclass_atom = RegisterClass(&wClass);
105 _inplace_wndclass_atom = 0;
108 HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
109 if( NULL != hbitmap )
113 pictDesc.cbSizeofstruct = sizeof(PICTDESC);
114 pictDesc.picType = PICTYPE_BITMAP;
115 pictDesc.bmp.hbitmap = hbitmap;
116 pictDesc.bmp.hpal = NULL;
118 if( FAILED(OleCreatePictureIndirect(&pictDesc, IID_IPicture, TRUE, reinterpret_cast<LPVOID*>(&_inplace_picture))) )
119 _inplace_picture = NULL;
124 VLCPluginClass::~VLCPluginClass()
126 if( 0 != _inplace_wndclass_atom )
127 UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
129 if( NULL != _inplace_picture )
130 _inplace_picture->Release();
133 STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)
138 if( (IID_IUnknown == riid)
139 || (IID_IClassFactory == riid) )
142 *ppv = reinterpret_cast<LPVOID>(this);
149 return E_NOINTERFACE;
152 STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)
154 return InterlockedIncrement(_p_class_ref);
157 STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)
159 ULONG refcount = InterlockedDecrement(_p_class_ref);
168 STDMETHODIMP VLCPluginClass::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
175 if( (NULL != pUnkOuter) && (IID_IUnknown != riid) ) {
176 return CLASS_E_NOAGGREGATION;
179 VLCPlugin *plugin = new VLCPlugin(this, pUnkOuter);
182 HRESULT hr = plugin->QueryInterface(riid, ppv);
183 // the following will destroy the object if QueryInterface() failed
187 return E_OUTOFMEMORY;
190 STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)
200 ////////////////////////////////////////////////////////////////////////
202 VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
212 vlcOleControl = new VLCOleControl(this);
213 vlcOleInPlaceObject = new VLCOleInPlaceObject(this);
214 vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);
215 vlcPersistStorage = new VLCPersistStorage(this);
216 vlcPersistStreamInit = new VLCPersistStreamInit(this);
217 vlcPersistPropertyBag = new VLCPersistPropertyBag(this);
218 vlcProvideClassInfo = new VLCProvideClassInfo(this);
219 vlcConnectionPointContainer = new VLCConnectionPointContainer(this);
220 vlcObjectSafety = new VLCObjectSafety(this);
221 vlcControl = new VLCControl(this);
222 vlcControl2 = new VLCControl2(this);
223 vlcViewObject = new VLCViewObject(this);
224 vlcDataObject = new VLCDataObject(this);
225 vlcOleObject = new VLCOleObject(this);
227 // configure controlling IUnknown interface for implemented interfaces
228 this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
231 _p_pict = p_class->getInPlacePict();
233 // make sure that persistable properties are initialized
237 VLCPlugin::~VLCPlugin()
240 delete vlcDataObject;
241 delete vlcViewObject;
244 delete vlcConnectionPointContainer;
245 delete vlcProvideClassInfo;
246 delete vlcPersistPropertyBag;
247 delete vlcPersistStreamInit;
248 delete vlcPersistStorage;
249 delete vlcOleInPlaceActiveObject;
250 delete vlcOleInPlaceObject;
251 delete vlcObjectSafety;
253 delete vlcOleControl;
257 SysFreeString(_bstr_mrl);
262 STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
267 if( IID_IUnknown == riid )
268 *ppv = reinterpret_cast<LPVOID>(this);
269 else if( IID_IOleObject == riid )
270 *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
271 else if( IID_IOleControl == riid )
272 *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
273 else if( IID_IOleWindow == riid )
274 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
275 else if( IID_IOleInPlaceObject == riid )
276 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
277 else if( IID_IOleInPlaceActiveObject == riid )
278 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
279 else if( IID_IPersist == riid )
280 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
281 else if( IID_IPersistStreamInit == riid )
282 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
283 else if( IID_IPersistStorage == riid )
284 *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
285 else if( IID_IPersistPropertyBag == riid )
286 *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
287 else if( IID_IProvideClassInfo == riid )
288 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
289 else if( IID_IProvideClassInfo2 == riid )
290 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
291 else if( IID_IConnectionPointContainer == riid )
292 *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
293 else if( IID_IObjectSafety == riid )
294 *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
295 else if( IID_IDispatch == riid )
296 *ppv = (CLSID_VLCPlugin2 == getClassID()) ?
297 reinterpret_cast<LPVOID>(vlcControl2) :
298 reinterpret_cast<LPVOID>(vlcControl);
299 else if( IID_IVLCControl == riid )
300 *ppv = reinterpret_cast<LPVOID>(vlcControl);
301 else if( IID_IVLCControl2 == riid )
302 *ppv = reinterpret_cast<LPVOID>(vlcControl2);
303 else if( IID_IViewObject == riid )
304 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
305 else if( IID_IViewObject2 == riid )
306 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
307 else if( IID_IDataObject == riid )
308 *ppv = reinterpret_cast<LPVOID>(vlcDataObject);
312 return E_NOINTERFACE;
314 ((LPUNKNOWN)*ppv)->AddRef();
318 STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)
320 return InterlockedIncrement((LONG *)&_i_ref);
323 STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
325 if( ! InterlockedDecrement((LONG *)&_i_ref) )
333 //////////////////////////////////////
335 HRESULT VLCPlugin::onInit(void)
337 if( NULL == _p_libvlc )
339 // initialize persistable properties
342 _bstr_baseurl = NULL;
348 // set default/preferred size (320x240) pixels in HIMETRIC
349 HDC hDC = CreateDevDC(NULL);
352 HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
357 return CO_E_ALREADYINITIALIZED;
360 HRESULT VLCPlugin::onLoad(void)
362 if( SysStringLen(_bstr_baseurl) == 0 )
365 ** try to retreive the base URL using the client site moniker, which for Internet Explorer
366 ** is the URL of the page the plugin is embedded into.
368 LPOLECLIENTSITE pClientSite;
369 if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
372 if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
374 LPMONIKER pContMoniker = NULL;
375 if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
376 OLEWHICHMK_CONTAINER, &pContMoniker)) )
379 if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &base_url)) )
382 ** check that the moniker name is a URL
384 if( UrlIsW(base_url, URLIS_URL) )
387 _bstr_baseurl = SysAllocString(base_url);
389 CoTaskMemFree(base_url);
399 HRESULT VLCPlugin::getVLCObject(int* i_vlc)
401 libvlc_instance_t *p_libvlc;
402 HRESULT result = getVLC(&p_libvlc);
403 if( SUCCEEDED(result) )
405 *i_vlc = libvlc_get_vlc_id(p_libvlc);
414 HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
416 extern HMODULE DllGetModule();
421 ** default initialization options
423 char *ppsz_argv[32] = { "vlc" };
427 DWORD i_type, i_data = MAX_PATH + 1;
428 char p_data[MAX_PATH + 1];
429 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
430 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
432 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
433 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
435 if( i_type == REG_SZ )
437 strcat( p_data, "\\plugins" );
438 ppsz_argv[ppsz_argc++] = "--plugin-path";
439 ppsz_argv[ppsz_argc++] = p_data;
442 RegCloseKey( h_key );
445 char p_path[MAX_PATH+1];
446 DWORD len = GetModuleFileNameA(DllGetModule(), p_path, sizeof(p_path));
450 ppsz_argv[0] = p_path;
453 // make sure plugin isn't affected with VLC single instance mode
454 ppsz_argv[ppsz_argc++] = "--no-one-instance";
456 /* common settings */
457 ppsz_argv[ppsz_argc++] = "-vv";
458 ppsz_argv[ppsz_argc++] = "--no-stats";
459 ppsz_argv[ppsz_argc++] = "--no-media-library";
460 ppsz_argv[ppsz_argc++] = "--intf";
461 ppsz_argv[ppsz_argc++] = "dummy";
463 // loop mode is a configuration option only
465 ppsz_argv[ppsz_argc++] = "--loop";
467 if( IsDebuggerPresent() )
470 ** VLC default threading mechanism is designed to be as compatible
471 ** with POSIX as possible. However when debugged on win32, threads
472 ** lose signals and eventually VLC get stuck during initialization.
473 ** threading support can be configured to be more debugging friendly
474 ** but it will be less compatible with POSIX.
475 ** This is done by initializing with the following options:
477 ppsz_argv[ppsz_argc++] = "--fast-mutex";
478 ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
481 _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL);
482 if( NULL == _p_libvlc )
488 // initial volume setting
489 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
492 libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
495 // initial playlist item
496 if( SysStringLen(_bstr_mrl) > 0 )
498 char *psz_mrl = NULL;
500 if( SysStringLen(_bstr_baseurl) > 0 )
502 DWORD len = INTERNET_MAX_URL_LENGTH;
503 LPOLESTR abs_url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*len);
504 if( NULL != abs_url )
507 ** if the MRL a relative URL, we should end up with an absolute URL
509 if( SUCCEEDED(UrlCombineW(_bstr_baseurl, _bstr_mrl, abs_url, &len,
510 URL_ESCAPE_UNSAFE|URL_PLUGGABLE_PROTOCOL)) )
512 psz_mrl = CStrFromBSTR(CP_UTF8, abs_url);
516 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
518 CoTaskMemFree(abs_url);
524 ** baseURL is empty, assume MRL is absolute
526 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
528 if( NULL != psz_mrl )
530 const char *options[1];
536 snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time);
537 options[i_options++] = timeBuffer;
539 // add default target to playlist
540 libvlc_playlist_add_extended(_p_libvlc, psz_mrl, NULL, i_options, options, NULL);
541 CoTaskMemFree(psz_mrl);
545 *pp_libvlc = _p_libvlc;
549 HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
554 case DISPID_AMBIENT_BACKCOLOR:
556 case DISPID_AMBIENT_DISPLAYNAME:
558 case DISPID_AMBIENT_FONT:
560 case DISPID_AMBIENT_FORECOLOR:
562 case DISPID_AMBIENT_LOCALEID:
564 case DISPID_AMBIENT_MESSAGEREFLECT:
566 case DISPID_AMBIENT_SCALEUNITS:
568 case DISPID_AMBIENT_TEXTALIGN:
570 case DISPID_AMBIENT_USERMODE:
573 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
575 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
578 case DISPID_AMBIENT_UIDEAD:
580 case DISPID_AMBIENT_SHOWGRABHANDLES:
582 case DISPID_AMBIENT_SHOWHATCHING:
584 case DISPID_AMBIENT_DISPLAYASDEFAULT:
586 case DISPID_AMBIENT_SUPPORTSMNEMONICS:
588 case DISPID_AMBIENT_AUTOCLIP:
590 case DISPID_AMBIENT_APPEARANCE:
592 case DISPID_AMBIENT_CODEPAGE:
595 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
597 setCodePage(V_I4(&v));
600 case DISPID_AMBIENT_PALETTE:
602 case DISPID_AMBIENT_CHARSET:
604 case DISPID_AMBIENT_RIGHTTOLEFT:
606 case DISPID_AMBIENT_TOPTOBOTTOM:
610 ** multiple property change, look up the ones we are interested in
614 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
616 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
620 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_CODEPAGE, v)) )
622 setCodePage(V_I4(&v));
629 HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
631 if( isInPlaceActive() )
633 onInPlaceDeactivate();
637 libvlc_instance_t* p_libvlc = _p_libvlc;
640 vlcDataObject->onClose();
642 libvlc_destroy(p_libvlc, NULL );
647 BOOL VLCPlugin::isInPlaceActive(void)
649 return (NULL != _inplacewnd);
652 HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
654 RECT clipRect = *lprcClipRect;
657 ** record keeping of control geometry within container
659 _posRect = *lprcPosRect;
662 ** Create a window for in place activated control.
663 ** the window geometry matches the control viewport
664 ** within container so that embedded video is always
665 ** properly displayed.
667 _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
668 "VLC Plugin In-Place Window",
669 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
672 lprcPosRect->right-lprcPosRect->left,
673 lprcPosRect->bottom-lprcPosRect->top,
676 _p_class->getHInstance(),
680 if( NULL == _inplacewnd )
683 SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
685 /* change cliprect coordinates system relative to window bounding rect */
686 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
688 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
689 SetWindowRgn(_inplacewnd, clipRgn, TRUE);
693 /* will run vlc if not done already */
694 libvlc_instance_t* p_libvlc;
695 HRESULT result = getVLC(&p_libvlc);
699 /* set internal video width and height */
700 libvlc_video_set_size(p_libvlc,
701 lprcPosRect->right-lprcPosRect->left,
702 lprcPosRect->bottom-lprcPosRect->top,
705 /* set internal video parent window */
706 libvlc_video_set_parent(p_libvlc,
707 reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
709 if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
711 libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
717 ShowWindow(_inplacewnd, SW_SHOW);
722 HRESULT VLCPlugin::onInPlaceDeactivate(void)
726 libvlc_playlist_stop(_p_libvlc, NULL);
730 DestroyWindow(_inplacewnd);
736 void VLCPlugin::setVisible(BOOL fVisible)
738 if( fVisible != _b_visible )
740 _b_visible = fVisible;
741 if( isInPlaceActive() )
743 ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
745 InvalidateRect(_inplacewnd, NULL, TRUE);
748 firePropChangedEvent(DISPID_Visible);
752 void VLCPlugin::setVolume(int volume)
756 else if( volume > 200 )
759 if( volume != _i_volume )
764 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
770 void VLCPlugin::setTime(int seconds)
775 if( seconds != _i_time )
777 setStartTime(_i_time);
780 libvlc_input_t *p_input = libvlc_playlist_get_input(_p_libvlc, NULL);
781 if( NULL != p_input )
783 libvlc_input_set_time(p_input, _i_time, NULL);
784 libvlc_input_free(p_input);
790 void VLCPlugin::setFocus(BOOL fFocus)
793 SetActiveWindow(_inplacewnd);
796 BOOL VLCPlugin::hasFocus(void)
798 return GetActiveWindow() == _inplacewnd;
801 void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
802 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
806 long width = lprcBounds->right-lprcBounds->left;
807 long height = lprcBounds->bottom-lprcBounds->top;
809 RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
810 FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
812 LPPICTURE pict = getPicture();
815 OLE_XSIZE_HIMETRIC picWidth;
816 OLE_YSIZE_HIMETRIC picHeight;
818 pict->get_Width(&picWidth);
819 pict->get_Height(&picHeight);
821 SIZEL picSize = { picWidth, picHeight };
823 if( NULL != hicTargetDev )
825 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
827 else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
829 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
830 DeleteDC(hicTargetDev);
833 if( picSize.cx > width-4 )
834 picSize.cx = width-4;
835 if( picSize.cy > height-4 )
836 picSize.cy = height-4;
838 LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
839 LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
841 if( NULL != lprcWBounds )
843 RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
844 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
845 0L, picHeight, picWidth, -picHeight, &wBounds);
848 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
849 0L, picHeight, picWidth, -picHeight, NULL);
854 SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
856 MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
857 LineTo(hdcDraw, bounds.left+width-1, bounds.top);
858 LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
859 LineTo(hdcDraw, bounds.left, bounds.top+height-1);
860 LineTo(hdcDraw, bounds.left, bounds.top);
864 void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
868 /** if VLC is playing, it may not display any VIDEO content
869 ** hence, draw control logo*/
870 HDC hdcDraw = CreateCompatibleDC(hdc);
871 if( NULL != hdcDraw )
873 SIZEL size = getExtent();
874 DPFromHimetric(hdc, (LPPOINT)&size, 1);
875 RECTL posRect = { 0, 0, size.cx, size.cy };
877 int width = bounds.right-bounds.left;
878 int height = bounds.bottom-bounds.top;
880 HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
881 if( NULL != hBitmap )
883 HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
885 if( (size.cx != width) || (size.cy != height) )
887 // needs to scale canvas
888 SetMapMode(hdcDraw, MM_ANISOTROPIC);
889 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
890 SetViewportExtEx(hdcDraw, width, height, NULL);
893 onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
895 SetMapMode(hdcDraw, MM_TEXT);
896 BitBlt(hdc, bounds.left, bounds.top,
901 SelectObject(hdcDraw, oldBmp);
902 DeleteObject(hBitmap);
909 void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
911 RECT clipRect = *lprcClipRect;
913 //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
916 ** record keeping of control geometry within container
918 _posRect = *lprcPosRect;
921 ** change in-place window geometry to match clipping region
923 SetWindowPos(_inplacewnd, NULL,
926 lprcPosRect->right-lprcPosRect->left,
927 lprcPosRect->bottom-lprcPosRect->top,
933 /* change cliprect coordinates system relative to window bounding rect */
934 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
935 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
936 SetWindowRgn(_inplacewnd, clipRgn, TRUE);
938 //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
941 libvlc_video_set_size(_p_libvlc,
942 lprcPosRect->right-lprcPosRect->left,
943 lprcPosRect->bottom-lprcPosRect->top,
948 void VLCPlugin::freezeEvents(BOOL freeze)
950 vlcConnectionPointContainer->freezeEvents(freeze);
953 void VLCPlugin::firePropChangedEvent(DISPID dispid)
955 vlcConnectionPointContainer->firePropChangedEvent(dispid);
958 void VLCPlugin::fireOnPlayEvent(void)
960 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
961 vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs);
964 void VLCPlugin::fireOnPauseEvent(void)
966 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
967 vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs);
970 void VLCPlugin::fireOnStopEvent(void)
972 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
973 vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);