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);
261 SysFreeString(_bstr_baseurl);
266 STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
271 if( IID_IUnknown == riid )
272 *ppv = reinterpret_cast<LPVOID>(this);
273 else if( IID_IOleObject == riid )
274 *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
275 else if( IID_IOleControl == riid )
276 *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
277 else if( IID_IOleWindow == riid )
278 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
279 else if( IID_IOleInPlaceObject == riid )
280 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
281 else if( IID_IOleInPlaceActiveObject == riid )
282 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
283 else if( IID_IPersist == riid )
284 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
285 else if( IID_IPersistStreamInit == riid )
286 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
287 else if( IID_IPersistStorage == riid )
288 *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
289 else if( IID_IPersistPropertyBag == riid )
290 *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
291 else if( IID_IProvideClassInfo == riid )
292 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
293 else if( IID_IProvideClassInfo2 == riid )
294 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
295 else if( IID_IConnectionPointContainer == riid )
296 *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
297 else if( IID_IObjectSafety == riid )
298 *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
299 else if( IID_IDispatch == riid )
300 *ppv = (CLSID_VLCPlugin2 == getClassID()) ?
301 reinterpret_cast<LPVOID>(vlcControl2) :
302 reinterpret_cast<LPVOID>(vlcControl);
303 else if( IID_IVLCControl == riid )
304 *ppv = reinterpret_cast<LPVOID>(vlcControl);
305 else if( IID_IVLCControl2 == riid )
306 *ppv = reinterpret_cast<LPVOID>(vlcControl2);
307 else if( IID_IViewObject == riid )
308 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
309 else if( IID_IViewObject2 == riid )
310 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
311 else if( IID_IDataObject == riid )
312 *ppv = reinterpret_cast<LPVOID>(vlcDataObject);
313 else if( IID_ISupportErrorInfo == riid )
314 *ppv = reinterpret_cast<LPVOID>(vlcSupportErrorInfo);
318 return E_NOINTERFACE;
320 ((LPUNKNOWN)*ppv)->AddRef();
324 STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)
326 return InterlockedIncrement((LONG *)&_i_ref);
329 STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
331 if( ! InterlockedDecrement((LONG *)&_i_ref) )
339 //////////////////////////////////////
341 HRESULT VLCPlugin::onInit(void)
343 if( NULL == _p_libvlc )
345 // initialize persistable properties
348 _bstr_baseurl = NULL;
354 // set default/preferred size (320x240) pixels in HIMETRIC
355 HDC hDC = CreateDevDC(NULL);
358 HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
363 return CO_E_ALREADYINITIALIZED;
366 HRESULT VLCPlugin::onLoad(void)
368 if( SysStringLen(_bstr_baseurl) == 0 )
371 ** try to retreive the base URL using the client site moniker, which for Internet Explorer
372 ** is the URL of the page the plugin is embedded into.
374 LPOLECLIENTSITE pClientSite;
375 if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
378 if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
380 LPMONIKER pContMoniker = NULL;
381 if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
382 OLEWHICHMK_CONTAINER, &pContMoniker)) )
385 if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &base_url)) )
388 ** check that the moniker name is a URL
390 if( UrlIsW(base_url, URLIS_URL) )
393 _bstr_baseurl = SysAllocString(base_url);
395 CoTaskMemFree(base_url);
405 HRESULT VLCPlugin::getVLCObject(int* i_vlc)
407 libvlc_instance_t *p_libvlc;
408 HRESULT result = getVLC(&p_libvlc);
409 if( SUCCEEDED(result) )
411 *i_vlc = libvlc_get_vlc_id(p_libvlc);
420 HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
422 extern HMODULE DllGetModule();
427 ** default initialization options
429 char *ppsz_argv[32] = { "vlc" };
432 char p_progpath[MAX_PATH];
434 TCHAR w_progpath[MAX_PATH];
435 DWORD len = GetModuleFileName(DllGetModule(), w_progpath, MAX_PATH);
438 len = WideCharToMultiByte(CP_UTF8, 0, w_progpath, len, p_progpath,
439 sizeof(p_progpath)-1, NULL, NULL);
442 p_progpath[len] = '\0';
443 ppsz_argv[0] = p_progpath;
448 ppsz_argv[ppsz_argc++] = "-vv";
451 char p_pluginpath[MAX_PATH];
452 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Software\\VideoLAN\\VLC"),
453 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
455 DWORD i_type, i_data = MAX_PATH;
456 TCHAR w_pluginpath[MAX_PATH];
457 if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type,
458 (LPBYTE)w_pluginpath, &i_data ) == ERROR_SUCCESS )
460 if( i_type == REG_SZ )
462 if( WideCharToMultiByte(CP_UTF8, 0, w_pluginpath, -1, p_pluginpath,
463 sizeof(p_pluginpath)-sizeof("\\plugins")+1, NULL, NULL) )
465 strcat( p_pluginpath, "\\plugins" );
466 ppsz_argv[ppsz_argc++] = "--plugin-path";
467 ppsz_argv[ppsz_argc++] = p_pluginpath;
471 RegCloseKey( h_key );
474 // make sure plugin isn't affected with VLC single instance mode
475 ppsz_argv[ppsz_argc++] = "--no-one-instance";
477 /* common settings */
478 ppsz_argv[ppsz_argc++] = "--no-stats";
479 ppsz_argv[ppsz_argc++] = "--no-media-library";
480 ppsz_argv[ppsz_argc++] = "--intf=dummy";
482 // loop mode is a configuration option only
484 ppsz_argv[ppsz_argc++] = "--loop";
486 if( IsDebuggerPresent() )
489 ** VLC default threading mechanism is designed to be as compatible
490 ** with POSIX as possible. However when debugged on win32, threads
491 ** lose signals and eventually VLC get stuck during initialization.
492 ** threading support can be configured to be more debugging friendly
493 ** but it will be less compatible with POSIX.
494 ** This is done by initializing with the following options:
496 ppsz_argv[ppsz_argc++] = "--fast-mutex";
497 ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
502 _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL);
503 if( NULL == _p_libvlc )
509 // initial volume setting
510 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
513 libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
516 // initial playlist item
517 if( SysStringLen(_bstr_mrl) > 0 )
519 char *psz_mrl = NULL;
521 if( SysStringLen(_bstr_baseurl) > 0 )
524 ** if the MRL a relative URL, we should end up with an absolute URL
526 LPWSTR abs_url = CombineURL(_bstr_baseurl, _bstr_mrl);
527 if( NULL != abs_url )
529 psz_mrl = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
530 CoTaskMemFree(abs_url);
534 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
540 ** baseURL is empty, assume MRL is absolute
542 psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
544 if( NULL != psz_mrl )
546 const char *options[1];
552 snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time);
553 options[i_options++] = timeBuffer;
555 // add default target to playlist
556 libvlc_playlist_add_extended(_p_libvlc, psz_mrl, NULL, i_options, options, NULL);
557 CoTaskMemFree(psz_mrl);
561 *pp_libvlc = _p_libvlc;
565 void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
567 vlcSupportErrorInfo->setErrorInfo( getClassID() == CLSID_VLCPlugin2 ?
568 OLESTR("VideoLAN.VLCPlugin.2") : OLESTR("VideoLAN.VLCPlugin.1"),
572 HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
577 case DISPID_AMBIENT_BACKCOLOR:
579 case DISPID_AMBIENT_DISPLAYNAME:
581 case DISPID_AMBIENT_FONT:
583 case DISPID_AMBIENT_FORECOLOR:
585 case DISPID_AMBIENT_LOCALEID:
587 case DISPID_AMBIENT_MESSAGEREFLECT:
589 case DISPID_AMBIENT_SCALEUNITS:
591 case DISPID_AMBIENT_TEXTALIGN:
593 case DISPID_AMBIENT_USERMODE:
596 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
598 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
601 case DISPID_AMBIENT_UIDEAD:
603 case DISPID_AMBIENT_SHOWGRABHANDLES:
605 case DISPID_AMBIENT_SHOWHATCHING:
607 case DISPID_AMBIENT_DISPLAYASDEFAULT:
609 case DISPID_AMBIENT_SUPPORTSMNEMONICS:
611 case DISPID_AMBIENT_AUTOCLIP:
613 case DISPID_AMBIENT_APPEARANCE:
615 case DISPID_AMBIENT_CODEPAGE:
618 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
620 setCodePage(V_I4(&v));
623 case DISPID_AMBIENT_PALETTE:
625 case DISPID_AMBIENT_CHARSET:
627 case DISPID_AMBIENT_RIGHTTOLEFT:
629 case DISPID_AMBIENT_TOPTOBOTTOM:
633 ** multiple property change, look up the ones we are interested in
637 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
639 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
643 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_CODEPAGE, v)) )
645 setCodePage(V_I4(&v));
652 HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
654 if( isInPlaceActive() )
656 onInPlaceDeactivate();
660 libvlc_instance_t* p_libvlc = _p_libvlc;
663 if( SUCCEEDED(vlcControl2->get_log(&p_log)) )
665 // make sure the log is disabled
666 p_log->put_verbosity(-1);
671 vlcDataObject->onClose();
673 libvlc_destroy(p_libvlc, NULL );
678 BOOL VLCPlugin::isInPlaceActive(void)
680 return (NULL != _inplacewnd);
683 HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
685 RECT clipRect = *lprcClipRect;
688 ** record keeping of control geometry within container
690 _posRect = *lprcPosRect;
693 ** Create a window for in place activated control.
694 ** the window geometry matches the control viewport
695 ** within container so that embedded video is always
696 ** properly displayed.
698 _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
699 TEXT("VLC Plugin In-Place Window"),
700 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
703 lprcPosRect->right-lprcPosRect->left,
704 lprcPosRect->bottom-lprcPosRect->top,
707 _p_class->getHInstance(),
711 if( NULL == _inplacewnd )
714 SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
716 /* change cliprect coordinates system relative to window bounding rect */
717 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
719 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
720 SetWindowRgn(_inplacewnd, clipRgn, TRUE);
724 /* will run vlc if not done already */
725 libvlc_instance_t* p_libvlc;
726 HRESULT result = getVLC(&p_libvlc);
730 /* set internal video width and height */
731 libvlc_video_set_size(p_libvlc,
732 lprcPosRect->right-lprcPosRect->left,
733 lprcPosRect->bottom-lprcPosRect->top,
736 /* set internal video parent window */
737 libvlc_video_set_parent(p_libvlc,
738 reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
740 if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
742 libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
748 ShowWindow(_inplacewnd, SW_SHOW);
753 HRESULT VLCPlugin::onInPlaceDeactivate(void)
757 libvlc_playlist_stop(_p_libvlc, NULL);
761 DestroyWindow(_inplacewnd);
767 void VLCPlugin::setVisible(BOOL fVisible)
769 if( fVisible != _b_visible )
771 _b_visible = fVisible;
772 if( isInPlaceActive() )
774 ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
776 InvalidateRect(_inplacewnd, NULL, TRUE);
779 firePropChangedEvent(DISPID_Visible);
783 void VLCPlugin::setVolume(int volume)
787 else if( volume > 200 )
790 if( volume != _i_volume )
795 libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
801 void VLCPlugin::setTime(int seconds)
806 if( seconds != _i_time )
808 setStartTime(_i_time);
811 libvlc_input_t *p_input = libvlc_playlist_get_input(_p_libvlc, NULL);
812 if( NULL != p_input )
814 libvlc_input_set_time(p_input, _i_time, NULL);
815 libvlc_input_free(p_input);
821 void VLCPlugin::setFocus(BOOL fFocus)
824 SetActiveWindow(_inplacewnd);
827 BOOL VLCPlugin::hasFocus(void)
829 return GetActiveWindow() == _inplacewnd;
832 void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
833 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
837 long width = lprcBounds->right-lprcBounds->left;
838 long height = lprcBounds->bottom-lprcBounds->top;
840 RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
841 FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
843 LPPICTURE pict = getPicture();
846 OLE_XSIZE_HIMETRIC picWidth;
847 OLE_YSIZE_HIMETRIC picHeight;
849 pict->get_Width(&picWidth);
850 pict->get_Height(&picHeight);
852 SIZEL picSize = { picWidth, picHeight };
854 if( NULL != hicTargetDev )
856 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
858 else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
860 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
861 DeleteDC(hicTargetDev);
864 if( picSize.cx > width-4 )
865 picSize.cx = width-4;
866 if( picSize.cy > height-4 )
867 picSize.cy = height-4;
869 LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
870 LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
872 if( NULL != lprcWBounds )
874 RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
875 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
876 0L, picHeight, picWidth, -picHeight, &wBounds);
879 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
880 0L, picHeight, picWidth, -picHeight, NULL);
885 SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
887 MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
888 LineTo(hdcDraw, bounds.left+width-1, bounds.top);
889 LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
890 LineTo(hdcDraw, bounds.left, bounds.top+height-1);
891 LineTo(hdcDraw, bounds.left, bounds.top);
895 void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
899 /** if VLC is playing, it may not display any VIDEO content
900 ** hence, draw control logo*/
901 HDC hdcDraw = CreateCompatibleDC(hdc);
902 if( NULL != hdcDraw )
904 SIZEL size = getExtent();
905 DPFromHimetric(hdc, (LPPOINT)&size, 1);
906 RECTL posRect = { 0, 0, size.cx, size.cy };
908 int width = bounds.right-bounds.left;
909 int height = bounds.bottom-bounds.top;
911 HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
912 if( NULL != hBitmap )
914 HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
916 if( (size.cx != width) || (size.cy != height) )
918 // needs to scale canvas
919 SetMapMode(hdcDraw, MM_ANISOTROPIC);
920 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
921 SetViewportExtEx(hdcDraw, width, height, NULL);
924 onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
926 SetMapMode(hdcDraw, MM_TEXT);
927 BitBlt(hdc, bounds.left, bounds.top,
932 SelectObject(hdcDraw, oldBmp);
933 DeleteObject(hBitmap);
940 void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
942 RECT clipRect = *lprcClipRect;
944 //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
947 ** record keeping of control geometry within container
949 _posRect = *lprcPosRect;
952 ** change in-place window geometry to match clipping region
954 SetWindowPos(_inplacewnd, NULL,
957 lprcPosRect->right-lprcPosRect->left,
958 lprcPosRect->bottom-lprcPosRect->top,
964 /* change cliprect coordinates system relative to window bounding rect */
965 OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
966 HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
967 SetWindowRgn(_inplacewnd, clipRgn, FALSE);
969 //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
972 libvlc_video_set_size(_p_libvlc,
973 lprcPosRect->right-lprcPosRect->left,
974 lprcPosRect->bottom-lprcPosRect->top,
979 void VLCPlugin::freezeEvents(BOOL freeze)
981 vlcConnectionPointContainer->freezeEvents(freeze);
984 void VLCPlugin::firePropChangedEvent(DISPID dispid)
986 vlcConnectionPointContainer->firePropChangedEvent(dispid);
989 void VLCPlugin::fireOnPlayEvent(void)
991 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
992 vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs);
995 void VLCPlugin::fireOnPauseEvent(void)
997 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
998 vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs);
1001 void VLCPlugin::fireOnStopEvent(void)
1003 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
1004 vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);