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)
109 if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )
111 wClass.style = CS_NOCLOSE|CS_DBLCLKS;
112 wClass.lpfnWndProc = VLCInPlaceClassWndProc;
113 wClass.cbClsExtra = 0;
114 wClass.cbWndExtra = 0;
115 wClass.hInstance = hInstance;
117 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
118 wClass.hbrBackground = NULL;
119 wClass.lpszMenuName = NULL;
120 wClass.lpszClassName = getInPlaceWndClassName();
122 _inplace_wndclass_atom = RegisterClass(&wClass);
126 _inplace_wndclass_atom = 0;
129 if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )
131 wClass.style = CS_NOCLOSE;
132 wClass.lpfnWndProc = VLCVideoClassWndProc;
133 wClass.cbClsExtra = 0;
134 wClass.cbWndExtra = 0;
135 wClass.hInstance = hInstance;
137 wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
138 wClass.hbrBackground = NULL;
139 wClass.lpszMenuName = NULL;
140 wClass.lpszClassName = getVideoWndClassName();
142 _video_wndclass_atom = RegisterClass(&wClass);
146 _video_wndclass_atom = 0;
149 HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
150 if( NULL != hbitmap )
154 pictDesc.cbSizeofstruct = sizeof(PICTDESC);
155 pictDesc.picType = PICTYPE_BITMAP;
156 pictDesc.bmp.hbitmap = hbitmap;
157 pictDesc.bmp.hpal = NULL;
159 if( FAILED(OleCreatePictureIndirect(&pictDesc, IID_IPicture, TRUE, reinterpret_cast<LPVOID*>(&_inplace_picture))) )
160 _inplace_picture = NULL;
165 VLCPluginClass::~VLCPluginClass()
167 if( 0 != _inplace_wndclass_atom )
168 UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
170 if( 0 != _video_wndclass_atom )
171 UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance);
173 if( NULL != _inplace_picture )
174 _inplace_picture->Release();
177 STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)
182 if( (IID_IUnknown == riid) || (IID_IClassFactory == riid) )
185 *ppv = reinterpret_cast<LPVOID>(this);
192 return E_NOINTERFACE;
195 STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)
197 return InterlockedIncrement(_p_class_ref);
200 STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)
202 ULONG refcount = InterlockedDecrement(_p_class_ref);
211 STDMETHODIMP VLCPluginClass::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
218 if( (NULL != pUnkOuter) && (IID_IUnknown != riid) ) {
219 return CLASS_E_NOAGGREGATION;
222 VLCPlugin *plugin = new VLCPlugin(this, pUnkOuter);
225 HRESULT hr = plugin->QueryInterface(riid, ppv);
229 return E_OUTOFMEMORY;
232 STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)
242 ////////////////////////////////////////////////////////////////////////
244 VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
259 vlcOleControl = new VLCOleControl(this);
260 vlcOleInPlaceObject = new VLCOleInPlaceObject(this);
261 vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);
262 vlcPersistStorage = new VLCPersistStorage(this);
263 vlcPersistStreamInit = new VLCPersistStreamInit(this);
264 vlcPersistPropertyBag = new VLCPersistPropertyBag(this);
265 vlcProvideClassInfo = new VLCProvideClassInfo(this);
266 vlcConnectionPointContainer = new VLCConnectionPointContainer(this);
267 vlcObjectSafety = new VLCObjectSafety(this);
268 vlcControl = new VLCControl(this);
269 vlcViewObject = new VLCViewObject(this);
270 vlcDataObject = new VLCDataObject(this);
271 vlcOleObject = new VLCOleObject(this);
273 // configure controlling IUnknown interface for implemented interfaces
274 this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
277 _p_pict = p_class->getInPlacePict();
279 // set default/preferred size (320x240) pixels in HIMETRIC
280 HDC hDC = CreateDevDC(NULL);
283 HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
287 VLCPlugin::~VLCPlugin()
290 delete vlcDataObject;
291 delete vlcViewObject;
293 delete vlcConnectionPointContainer;
294 delete vlcProvideClassInfo;
295 delete vlcPersistPropertyBag;
296 delete vlcPersistStreamInit;
297 delete vlcPersistStorage;
298 delete vlcOleInPlaceActiveObject;
299 delete vlcOleInPlaceObject;
300 delete vlcObjectSafety;
302 delete vlcOleControl;
306 SysFreeString(_bstr_mrl),
311 STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
316 if( IID_IUnknown == riid )
317 *ppv = reinterpret_cast<LPVOID>(this);
318 else if( IID_IOleObject == riid )
319 *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
320 else if( IID_IOleControl == riid )
321 *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
322 else if( IID_IOleWindow == riid )
323 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
324 else if( IID_IOleInPlaceObject == riid )
325 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
326 else if( IID_IOleInPlaceActiveObject == riid )
327 *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
328 else if( IID_IPersist == riid )
329 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
330 else if( IID_IPersistStreamInit == riid )
331 *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
332 else if( IID_IPersistStorage == riid )
333 *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
334 else if( IID_IPersistPropertyBag == riid )
335 *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
336 else if( IID_IProvideClassInfo == riid )
337 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
338 else if( IID_IProvideClassInfo2 == riid )
339 *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
340 else if( IID_IConnectionPointContainer == riid )
341 *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
342 else if( IID_IObjectSafety == riid )
343 *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
344 else if( IID_IDispatch == riid )
345 *ppv = reinterpret_cast<LPVOID>(vlcControl);
346 else if( IID_IVLCControl == riid )
347 *ppv = reinterpret_cast<LPVOID>(vlcControl);
348 else if( IID_IViewObject == riid )
349 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
350 else if( IID_IViewObject2 == riid )
351 *ppv = reinterpret_cast<LPVOID>(vlcViewObject);
352 else if( IID_IDataObject == riid )
353 *ppv = reinterpret_cast<LPVOID>(vlcDataObject);
357 return E_NOINTERFACE;
359 ((LPUNKNOWN)*ppv)->AddRef();
363 STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)
365 return InterlockedIncrement((LONG *)&_i_ref);
368 STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
370 if( ! InterlockedDecrement((LONG *)&_i_ref) )
378 //////////////////////////////////////
381 ** we use a window to represent plugin viewport,
382 ** whose geometry is limited by the clipping rectangle
383 ** all drawing within this window must follow must
384 ** follow coordinates system described in lprPosRect
387 static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
390 bounds.right = lprPosRect->right-lprPosRect->left;
392 if( lprClipRect->left <= lprPosRect->left )
394 // left side is not clipped out
397 if( lprClipRect->right >= lprPosRect->right )
399 // right side is not clipped out, no change
401 else if( lprClipRect->right >= lprPosRect->left )
403 // right side is clipped out
404 lprPosRect->right = lprClipRect->right;
408 // outside of clipping rectange, not visible
409 lprPosRect->right = lprPosRect->left;
414 // left side is clipped out
415 bounds.left = lprPosRect->left-lprClipRect->left;
416 bounds.right += bounds.left;
418 lprPosRect->left = lprClipRect->left;
419 if( lprClipRect->right >= lprPosRect->right )
421 // right side is not clipped out
425 // right side is clipped out
426 lprPosRect->right = lprClipRect->right;
430 bounds.bottom = lprPosRect->bottom-lprPosRect->top;
432 if( lprClipRect->top <= lprPosRect->top )
434 // top side is not clipped out
437 if( lprClipRect->bottom >= lprPosRect->bottom )
439 // bottom side is not clipped out, no change
441 else if( lprClipRect->bottom >= lprPosRect->top )
443 // bottom side is clipped out
444 lprPosRect->bottom = lprClipRect->bottom;
448 // outside of clipping rectange, not visible
449 lprPosRect->right = lprPosRect->left;
454 bounds.top = lprPosRect->top-lprClipRect->top;
455 bounds.bottom += bounds.top;
457 lprPosRect->top = lprClipRect->top;
458 if( lprClipRect->bottom >= lprPosRect->bottom )
460 // bottom side is not clipped out
464 // bottom side is clipped out
465 lprPosRect->bottom = lprClipRect->bottom;
468 *lprClipRect = *lprPosRect;
469 *lprPosRect = bounds;
472 HRESULT VLCPlugin::onInit(void)
476 //#ifdef ACTIVEX_DEBUG
478 char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" };
480 char *ppsz_argv[] = { "vlc", "-vv" };
483 DWORD i_type, i_data = MAX_PATH + 1;
484 char p_data[MAX_PATH + 1];
485 if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
486 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
488 if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
489 (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
491 if( i_type == REG_SZ )
493 strcat( p_data, "\\vlc" );
494 ppsz_argv[0] = p_data;
497 RegCloseKey( h_key );
501 ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
504 _i_vlc = VLC_Create();
506 if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) )
514 return CO_E_ALREADYINITIALIZED;
517 HRESULT VLCPlugin::onLoad(void)
520 VLC_VolumeMute(_i_vlc);
522 if( NULL != _bstr_mrl )
525 ** try to combine MRL with client site moniker, which for Internet Explorer
526 ** is the URL of the page the plugin is embedded into. Hence, if the MRL
527 ** is a relative URL, we should end up with an absolute URL
529 IOleClientSite *pClientSite;
530 if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) )
533 if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
535 LPMONIKER pContMoniker = NULL;
536 if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
537 OLEWHICHMK_CONTAINER, &pContMoniker)) )
540 if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &name)) )
542 if( UrlIsW(name, URLIS_URL) )
544 LPOLESTR url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*INTERNET_MAX_URL_LENGTH);
547 DWORD len = INTERNET_MAX_URL_LENGTH;
548 if( SUCCEEDED(UrlCombineW(name, _bstr_mrl, url, &len,
549 URL_ESCAPE_UNSAFE)) )
551 SysFreeString(_bstr_mrl);
552 _bstr_mrl = SysAllocString(url);
559 pContMoniker->Release();
563 pClientSite->Release();
566 char *psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
567 if( NULL != psz_mrl )
569 // add default target to playlist
571 int cOptionsCount = 0;
575 cOptions[cOptionsCount++] = "loop";
577 VLC_AddTarget(_i_vlc, psz_mrl, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
578 CoTaskMemFree(psz_mrl);
585 HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
590 case DISPID_AMBIENT_BACKCOLOR:
592 case DISPID_AMBIENT_DISPLAYNAME:
594 case DISPID_AMBIENT_FONT:
596 case DISPID_AMBIENT_FORECOLOR:
598 case DISPID_AMBIENT_LOCALEID:
600 case DISPID_AMBIENT_MESSAGEREFLECT:
602 case DISPID_AMBIENT_SCALEUNITS:
604 case DISPID_AMBIENT_TEXTALIGN:
606 case DISPID_AMBIENT_USERMODE:
609 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
611 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
615 case DISPID_AMBIENT_UIDEAD:
617 case DISPID_AMBIENT_SHOWGRABHANDLES:
619 case DISPID_AMBIENT_SHOWHATCHING:
621 case DISPID_AMBIENT_DISPLAYASDEFAULT:
623 case DISPID_AMBIENT_SUPPORTSMNEMONICS:
625 case DISPID_AMBIENT_AUTOCLIP:
627 case DISPID_AMBIENT_APPEARANCE:
629 case DISPID_AMBIENT_CODEPAGE:
632 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
634 setCodePage(V_I4(&v));
637 case DISPID_AMBIENT_PALETTE:
639 case DISPID_AMBIENT_CHARSET:
641 case DISPID_AMBIENT_RIGHTTOLEFT:
643 case DISPID_AMBIENT_TOPTOBOTTOM:
648 if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
650 setUserMode(V_BOOL(&v) != VARIANT_FALSE);
655 if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
657 setCodePage(V_I4(&v));
664 HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
671 if( isInPlaceActive() )
673 onInPlaceDeactivate();
675 vlcDataObject->onClose();
683 BOOL VLCPlugin::isInPlaceActive(void)
685 return (NULL != _inplacewnd);
688 HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
690 RECT posRect = *lprcPosRect;
691 RECT clipRect = *lprcClipRect;
694 ** record keeping of control geometry within container
699 ** convert posRect & clipRect to match control viewport coordinates
701 getViewportCoords(&posRect, &clipRect);
704 ** Create a window for in place activated control.
705 ** the window geometry represents the control viewport
706 ** so that embedded video is always properly clipped.
708 _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
709 "VLC Plugin In-Place Window",
710 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
713 clipRect.right-clipRect.left,
714 clipRect.bottom-clipRect.top,
717 _p_class->getHInstance(),
721 if( NULL == _inplacewnd )
724 SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
727 ** VLC embedded video geometry automatically matches parent window.
728 ** hence create a child window so that video position and size
729 ** is always correct relative to the viewport bounds
731 _videownd = CreateWindow(_p_class->getVideoWndClassName(),
732 "VLC Plugin Video Window",
733 WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
736 posRect.right-posRect.left,
737 posRect.bottom-posRect.top,
740 _p_class->getHInstance(),
744 if( NULL == _videownd )
746 DestroyWindow(_inplacewnd);
750 SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
753 ShowWindow(_inplacewnd, SW_SHOWNORMAL);
755 /* horrible cast there */
757 val.i_int = reinterpret_cast<int>(_videownd);
758 VLC_VariableSet(_i_vlc, "drawable", val);
759 val.i_int = posRect.right-posRect.left;
760 VLC_VariableSet(_i_vlc, "width", val);
761 val.i_int = posRect.bottom-posRect.top;
762 VLC_VariableSet(_i_vlc, "height", val);
764 if( _b_usermode && _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
772 HRESULT VLCPlugin::onInPlaceDeactivate(void)
777 DestroyWindow(_videownd);
779 DestroyWindow(_inplacewnd);
785 void VLCPlugin::setVisible(BOOL fVisible)
787 _b_visible = fVisible;
788 if( isInPlaceActive() )
789 ShowWindow(_inplacewnd, fVisible ? SW_SHOWNORMAL : SW_HIDE);
790 firePropChangedEvent(DISPID_Visible);
793 void VLCPlugin::setFocus(BOOL fFocus)
796 SetActiveWindow(_inplacewnd);
799 BOOL VLCPlugin::hasFocus(void)
801 return GetActiveWindow() == _inplacewnd;
804 void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
805 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
809 long width = lprcBounds->right-lprcBounds->left;
810 long height = lprcBounds->bottom-lprcBounds->top;
812 RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
813 FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
815 LPPICTURE pict = getPicture();
818 OLE_XSIZE_HIMETRIC picWidth;
819 OLE_YSIZE_HIMETRIC picHeight;
821 pict->get_Width(&picWidth);
822 pict->get_Height(&picHeight);
824 SIZEL picSize = { picWidth, picHeight };
826 if( NULL != hicTargetDev )
828 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
830 else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
832 DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
833 DeleteDC(hicTargetDev);
836 if( picSize.cx > width-4 )
837 picSize.cx = width-4;
838 if( picSize.cy > height-4 )
839 picSize.cy = height-4;
841 LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
842 LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
844 if( NULL != lprcWBounds )
846 RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
847 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
848 0L, picHeight, picWidth, -picHeight, &wBounds);
851 pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
852 0L, picHeight, picWidth, -picHeight, NULL);
857 SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
859 MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
860 LineTo(hdcDraw, bounds.left+width-1, bounds.top);
861 LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
862 LineTo(hdcDraw, bounds.left, bounds.top+height-1);
863 LineTo(hdcDraw, bounds.left, bounds.top);
867 void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
871 /** if VLC is playing, it may not display any VIDEO content
872 ** hence, draw control logo*/
873 HDC hdcDraw = CreateCompatibleDC(hdc);
874 if( NULL != hdcDraw )
876 SIZEL size = getExtent();
877 DPFromHimetric(hdc, (LPPOINT)&size, 1);
878 RECTL posRect = { 0, 0, size.cx, size.cy };
880 int width = bounds.right-bounds.left;
881 int height = bounds.bottom-bounds.top;
883 HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
884 if( NULL != hBitmap )
886 HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
888 if( (size.cx != width) || (size.cx != height) )
890 // needs to scale canvas
891 SetMapMode(hdcDraw, MM_ANISOTROPIC);
892 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
893 SetViewportExtEx(hdcDraw, width, height, NULL);
896 onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
898 SetMapMode(hdcDraw, MM_TEXT);
899 BitBlt(hdc, bounds.left, bounds.top,
904 SelectObject(hdcDraw, oldBmp);
905 DeleteObject(hBitmap);
912 void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
914 RECT clipRect = *lprcClipRect;
915 RECT posRect = *lprcPosRect;
917 //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
920 ** record keeping of control geometry within container
925 ** convert posRect & clipRect to match control viewport coordinates
927 getViewportCoords(&posRect, &clipRect);
930 ** change in-place window geometry to match clipping region
932 SetWindowPos(_inplacewnd, NULL,
935 clipRect.right-clipRect.left,
936 clipRect.bottom-clipRect.top,
943 ** change video window geometry to match object bounds within clipping region
945 SetWindowPos(_videownd, NULL,
948 posRect.right-posRect.left,
949 posRect.bottom-posRect.top,
955 //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
957 val.i_int = posRect.right-posRect.left;
958 VLC_VariableSet(_i_vlc, "width", val);
959 val.i_int = posRect.bottom-posRect.top;
960 VLC_VariableSet(_i_vlc, "height", val);
963 void VLCPlugin::freezeEvents(BOOL freeze)
965 vlcConnectionPointContainer->freezeEvents(freeze);
968 void VLCPlugin::firePropChangedEvent(DISPID dispid)
970 vlcConnectionPointContainer->firePropChangedEvent(dispid);
973 void VLCPlugin::fireOnPlayEvent(void)
975 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
976 vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs);
979 void VLCPlugin::fireOnPauseEvent(void)
981 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
982 vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs);
985 void VLCPlugin::fireOnStopEvent(void)
987 DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
988 vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);