X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=activex%2Fplugin.cpp;h=ca23d48cc840122446e175da43dca74ba970ebae;hb=aaac24cc80159471e0275103e6d1caa75e33126f;hp=9a96662d7e31cc3b3ec62e68b944b9d1dd6104f8;hpb=2f53a04a1204337abacebcf83b5f6bcdd17336e0;p=vlc diff --git a/activex/plugin.cpp b/activex/plugin.cpp index 9a96662d7e..ca23d48cc8 100644 --- a/activex/plugin.cpp +++ b/activex/plugin.cpp @@ -36,6 +36,7 @@ #include "vlccontrol2.h" #include "viewobject.h" #include "dataobject.h" +#include "supporterrorinfo.h" #include "utils.h" @@ -52,26 +53,6 @@ using namespace std; //class factory static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch( uMsg ) - { - case WM_ERASEBKGND: - return 1L; - - case WM_PAINT: - PAINTSTRUCT ps; - if( GetUpdateRect(hWnd, NULL, FALSE) ) - { - BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - return 0L; - - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } -}; - -static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { VLCPlugin *p_instance = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch( uMsg ) @@ -117,7 +98,7 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID wClass.hbrBackground = NULL; wClass.lpszMenuName = NULL; wClass.lpszClassName = getInPlaceWndClassName(); - + _inplace_wndclass_atom = RegisterClass(&wClass); } else @@ -125,26 +106,6 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID _inplace_wndclass_atom = 0; } - if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) ) - { - wClass.style = CS_NOCLOSE; - wClass.lpfnWndProc = VLCVideoClassWndProc; - wClass.cbClsExtra = 0; - wClass.cbWndExtra = 0; - wClass.hInstance = hInstance; - wClass.hIcon = NULL; - wClass.hCursor = LoadCursor(NULL, IDC_ARROW); - wClass.hbrBackground = NULL; - wClass.lpszMenuName = NULL; - wClass.lpszClassName = getVideoWndClassName(); - - _video_wndclass_atom = RegisterClass(&wClass); - } - else - { - _video_wndclass_atom = 0; - } - HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); if( NULL != hbitmap ) { @@ -166,9 +127,6 @@ VLCPluginClass::~VLCPluginClass() if( 0 != _inplace_wndclass_atom ) UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance); - if( 0 != _video_wndclass_atom ) - UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance); - if( NULL != _inplace_picture ) _inplace_picture->Release(); }; @@ -234,7 +192,7 @@ STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock) { if( fLock ) AddRef(); - else + else Release(); return S_OK; @@ -244,7 +202,6 @@ STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock) VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : _inplacewnd(NULL), - _videownd(NULL), _p_class(p_class), _i_ref(1UL), _p_libvlc(NULL), @@ -267,6 +224,7 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : vlcViewObject = new VLCViewObject(this); vlcDataObject = new VLCDataObject(this); vlcOleObject = new VLCOleObject(this); + vlcSupportErrorInfo = new VLCSupportErrorInfo(this); // configure controlling IUnknown interface for implemented interfaces this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast(this); @@ -280,6 +238,13 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : VLCPlugin::~VLCPlugin() { + /* + ** bump refcount to avoid recursive release from + ** following interfaces when releasing this interface + */ + AddRef(); + + delete vlcSupportErrorInfo; delete vlcOleObject; delete vlcDataObject; delete vlcViewObject; @@ -299,6 +264,7 @@ VLCPlugin::~VLCPlugin() _p_pict->Release(); SysFreeString(_bstr_mrl); + SysFreeString(_bstr_baseurl); _p_class->Release(); }; @@ -350,6 +316,8 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv) *ppv = reinterpret_cast(vlcViewObject); else if( IID_IDataObject == riid ) *ppv = reinterpret_cast(vlcDataObject); + else if( IID_ISupportErrorInfo == riid ) + *ppv = reinterpret_cast(vlcSupportErrorInfo); else { *ppv = NULL; @@ -376,98 +344,6 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void) ////////////////////////////////////// -/* -** we use a window to represent plugin viewport, -** whose geometry is limited by the clipping rectangle -** all drawing within this window must follow must -** follow coordinates system described in lprPosRect -*/ - -static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect) -{ - RECT bounds; - bounds.right = lprPosRect->right-lprPosRect->left; - - if( lprClipRect->left <= lprPosRect->left ) - { - // left side is not clipped out - bounds.left = 0; - - if( lprClipRect->right >= lprPosRect->right ) - { - // right side is not clipped out, no change - } - else if( lprClipRect->right >= lprPosRect->left ) - { - // right side is clipped out - lprPosRect->right = lprClipRect->right; - } - else - { - // outside of clipping rectange, not visible - lprPosRect->right = lprPosRect->left; - } - } - else - { - // left side is clipped out - bounds.left = lprPosRect->left-lprClipRect->left; - bounds.right += bounds.left; - - lprPosRect->left = lprClipRect->left; - if( lprClipRect->right >= lprPosRect->right ) - { - // right side is not clipped out - } - else - { - // right side is clipped out - lprPosRect->right = lprClipRect->right; - } - } - - bounds.bottom = lprPosRect->bottom-lprPosRect->top; - - if( lprClipRect->top <= lprPosRect->top ) - { - // top side is not clipped out - bounds.top = 0; - - if( lprClipRect->bottom >= lprPosRect->bottom ) - { - // bottom side is not clipped out, no change - } - else if( lprClipRect->bottom >= lprPosRect->top ) - { - // bottom side is clipped out - lprPosRect->bottom = lprClipRect->bottom; - } - else - { - // outside of clipping rectange, not visible - lprPosRect->right = lprPosRect->left; - } - } - else - { - bounds.top = lprPosRect->top-lprClipRect->top; - bounds.bottom += bounds.top; - - lprPosRect->top = lprClipRect->top; - if( lprClipRect->bottom >= lprPosRect->bottom ) - { - // bottom side is not clipped out - } - else - { - // bottom side is clipped out - lprPosRect->bottom = lprClipRect->bottom; - } - } - *lprClipRect = *lprPosRect; - *lprPosRect = bounds; -}; - HRESULT VLCPlugin::onInit(void) { if( NULL == _p_libvlc ) @@ -481,6 +357,7 @@ HRESULT VLCPlugin::onInit(void) _b_mute = FALSE; _i_volume = 50; _i_time = 0; + _i_backcolor = 0; // set default/preferred size (320x240) pixels in HIMETRIC HDC hDC = CreateDevDC(NULL); _extent.cx = 320; @@ -499,7 +376,7 @@ HRESULT VLCPlugin::onLoad(void) { /* ** try to retreive the base URL using the client site moniker, which for Internet Explorer - ** is the URL of the page the plugin is embedded into. + ** is the URL of the page the plugin is embedded into. */ LPOLECLIENTSITE pClientSite; if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) ) @@ -520,7 +397,7 @@ HRESULT VLCPlugin::onLoad(void) if( UrlIsW(base_url, URLIS_URL) ) { /* copy base URL */ - _bstr_mrl = SysAllocString(base_url); + _bstr_baseurl = SysAllocString(base_url); } CoTaskMemFree(base_url); } @@ -549,6 +426,8 @@ HRESULT VLCPlugin::getVLCObject(int* i_vlc) HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) { + extern HMODULE DllGetModule(); + if( ! isRunning() ) { /* @@ -557,69 +436,60 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) char *ppsz_argv[32] = { "vlc" }; int ppsz_argc = 1; + char p_progpath[MAX_PATH]; + { + TCHAR w_progpath[MAX_PATH]; + DWORD len = GetModuleFileName(DllGetModule(), w_progpath, MAX_PATH); + if( len > 0 ) + { + len = WideCharToMultiByte(CP_UTF8, 0, w_progpath, len, p_progpath, + sizeof(p_progpath)-1, NULL, NULL); + if( len > 0 ) + { + p_progpath[len] = '\0'; + ppsz_argv[0] = p_progpath; + } + } + } + + ppsz_argv[ppsz_argc++] = "-vv"; + HKEY h_key; - DWORD i_type, i_data = MAX_PATH + 1; - char p_data[MAX_PATH + 1]; - if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC", + char p_pluginpath[MAX_PATH]; + if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Software\\VideoLAN\\VLC"), 0, KEY_READ, &h_key ) == ERROR_SUCCESS ) { - if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type, - (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS ) - { - if( i_type == REG_SZ ) - { - strcat( p_data, "\\vlc" ); - ppsz_argv[0] = p_data; - } - } - RegCloseKey( h_key ); + DWORD i_type, i_data = MAX_PATH; + TCHAR w_pluginpath[MAX_PATH]; + if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type, + (LPBYTE)w_pluginpath, &i_data ) == ERROR_SUCCESS ) + { + if( i_type == REG_SZ ) + { + if( WideCharToMultiByte(CP_UTF8, 0, w_pluginpath, -1, p_pluginpath, + sizeof(p_pluginpath)-sizeof("\\plugins")+1, NULL, NULL) ) + { + strcat( p_pluginpath, "\\plugins" ); + ppsz_argv[ppsz_argc++] = "--plugin-path"; + ppsz_argv[ppsz_argc++] = p_pluginpath; + } + } + } + RegCloseKey( h_key ); } -#if 0 - ppsz_argv[0] = "C:\\cygwin\\home\\damienf\\vlc-trunk\\vlc"; -#endif - // make sure plugin isn't affected with VLC single instance mode ppsz_argv[ppsz_argc++] = "--no-one-instance"; /* common settings */ - ppsz_argv[ppsz_argc++] = "-vv"; ppsz_argv[ppsz_argc++] = "--no-stats"; ppsz_argv[ppsz_argc++] = "--no-media-library"; - ppsz_argv[ppsz_argc++] = "--intf"; - ppsz_argv[ppsz_argc++] = "dummy"; + ppsz_argv[ppsz_argc++] = "--intf=dummy"; // loop mode is a configuration option only if( _b_autoloop ) ppsz_argv[ppsz_argc++] = "--loop"; - // initial volume setting - char volBuffer[16]; - ppsz_argv[ppsz_argc++] = "--volume"; - if( _b_mute ) - { - ppsz_argv[ppsz_argc++] = "0"; - } - else - { - snprintf(volBuffer, sizeof(volBuffer), "%d", _i_volume); - ppsz_argv[ppsz_argc++] = volBuffer; - } - - if( IsDebuggerPresent() ) - { - /* - ** VLC default threading mechanism is designed to be as compatible - ** with POSIX as possible. However when debugged on win32, threads - ** lose signals and eventually VLC get stuck during initialization. - ** threading support can be configured to be more debugging friendly - ** but it will be less compatible with POSIX. - ** This is done by initializing with the following options: - */ - ppsz_argv[ppsz_argc++] = "--fast-mutex"; - ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1"; - } - _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL); if( NULL == _p_libvlc ) { @@ -627,26 +497,40 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) return E_FAIL; } + // initial volume setting + libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL); + if( _b_mute ) + { + libvlc_audio_set_mute(_p_libvlc, TRUE, NULL); + } + + // initial playlist item if( SysStringLen(_bstr_mrl) > 0 ) { char *psz_mrl = NULL; - DWORD len = INTERNET_MAX_URL_LENGTH; - LPOLESTR abs_url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*len); - if( NULL != abs_url ) + + if( SysStringLen(_bstr_baseurl) > 0 ) { /* ** if the MRL a relative URL, we should end up with an absolute URL */ - if( SUCCEEDED(UrlCombineW(_bstr_baseurl, _bstr_mrl, abs_url, &len, - URL_ESCAPE_UNSAFE|URL_PLUGGABLE_PROTOCOL)) ) + LPWSTR abs_url = CombineURL(_bstr_baseurl, _bstr_mrl); + if( NULL != abs_url ) { - psz_mrl = CStrFromBSTR(CP_UTF8, abs_url); + psz_mrl = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url)); + CoTaskMemFree(abs_url); } else { psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl); } - CoTaskMemFree(abs_url); + } + else + { + /* + ** baseURL is empty, assume MRL is absolute + */ + psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl); } if( NULL != psz_mrl ) { @@ -669,12 +553,25 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) return S_OK; }; +void VLCPlugin::setErrorInfo(REFIID riid, const char *description) +{ + vlcSupportErrorInfo->setErrorInfo( getClassID() == CLSID_VLCPlugin2 ? + OLESTR("VideoLAN.VLCPlugin.2") : OLESTR("VideoLAN.VLCPlugin.1"), + riid, description ); +}; + HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID) { VARIANT v; switch( dispID ) { case DISPID_AMBIENT_BACKCOLOR: + VariantInit(&v); + V_VT(&v) = VT_I4; + if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) ) + { + setBackColor(V_I4(&v)); + } break; case DISPID_AMBIENT_DISPLAYNAME: break; @@ -759,10 +656,18 @@ HRESULT VLCPlugin::onClose(DWORD dwSaveOption) { libvlc_instance_t* p_libvlc = _p_libvlc; + IVLCLog *p_log; + if( SUCCEEDED(vlcControl2->get_log(&p_log)) ) + { + // make sure the log is disabled + p_log->put_verbosity(-1); + p_log->Release(); + } + _p_libvlc = NULL; vlcDataObject->onClose(); - libvlc_destroy(p_libvlc, NULL ); + libvlc_release(p_libvlc, NULL ); } return S_OK; }; @@ -774,32 +679,26 @@ BOOL VLCPlugin::isInPlaceActive(void) HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect) { - RECT posRect = *lprcPosRect; RECT clipRect = *lprcClipRect; /* ** record keeping of control geometry within container - */ - _posRect = posRect; - - /* - ** convert posRect & clipRect to match control viewport coordinates */ - getViewportCoords(&posRect, &clipRect); + _posRect = *lprcPosRect; /* ** Create a window for in place activated control. ** the window geometry matches the control viewport ** within container so that embedded video is always - ** properly clipped. + ** properly displayed. */ _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(), - "VLC Plugin In-Place Window", + TEXT("VLC Plugin In-Place Window"), WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, - clipRect.left, - clipRect.top, - clipRect.right-clipRect.left, - clipRect.bottom-clipRect.top, + lprcPosRect->left, + lprcPosRect->top, + lprcPosRect->right-lprcPosRect->left, + lprcPosRect->bottom-lprcPosRect->top, hwndParent, 0, _p_class->getHInstance(), @@ -811,32 +710,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast(this)); - /* - ** VLC embedded video automatically grows to cover client - ** area of parent window. - ** hence create a such a 'parent' window whose geometry - ** is always correct relative to the viewport bounds - */ - _videownd = CreateWindow(_p_class->getVideoWndClassName(), - "VLC Plugin Video Window", - WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE, - posRect.left, - posRect.top, - posRect.right-posRect.left, - posRect.bottom-posRect.top, - _inplacewnd, - 0, - _p_class->getHInstance(), - NULL - ); + /* change cliprect coordinates system relative to window bounding rect */ + OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top); - if( NULL == _videownd ) - { - DestroyWindow(_inplacewnd); - return E_FAIL; - } - - SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast(this)); + HRGN clipRgn = CreateRectRgnIndirect(&clipRect); + SetWindowRgn(_inplacewnd, clipRgn, TRUE); if( _b_usermode ) { @@ -848,13 +726,13 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc /* set internal video width and height */ libvlc_video_set_size(p_libvlc, - posRect.right-posRect.left, - posRect.bottom-posRect.top, + lprcPosRect->right-lprcPosRect->left, + lprcPosRect->bottom-lprcPosRect->top, NULL ); /* set internal video parent window */ libvlc_video_set_parent(p_libvlc, - reinterpret_cast(_videownd), NULL); + reinterpret_cast(_inplacewnd), NULL); if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) ) { @@ -877,11 +755,9 @@ HRESULT VLCPlugin::onInPlaceDeactivate(void) fireOnStopEvent(); } - DestroyWindow(_videownd); - _videownd = NULL; DestroyWindow(_inplacewnd); _inplacewnd = NULL; - + return S_OK; }; @@ -894,7 +770,7 @@ void VLCPlugin::setVisible(BOOL fVisible) { ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE); if( fVisible ) - InvalidateRect(_videownd, NULL, TRUE); + InvalidateRect(_inplacewnd, NULL, TRUE); } setDirty(TRUE); firePropChangedEvent(DISPID_Visible); @@ -919,6 +795,19 @@ void VLCPlugin::setVolume(int volume) } }; +void VLCPlugin::setBackColor(OLE_COLOR backcolor) +{ + if( _i_backcolor != backcolor ) + { + _i_backcolor = backcolor; + if( isInPlaceActive() ) + { + + } + setDirty(TRUE); + } +}; + void VLCPlugin::setTime(int seconds) { if( seconds < 0 ) @@ -929,11 +818,11 @@ void VLCPlugin::setTime(int seconds) setStartTime(_i_time); if( isRunning() ) { - libvlc_input_t *p_input = libvlc_playlist_get_input(_p_libvlc, NULL); - if( NULL != p_input ) + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(_p_libvlc, NULL); + if( NULL != p_md ) { - libvlc_input_set_time(p_input, _i_time, NULL); - libvlc_input_free(p_input); + libvlc_media_instance_set_time(p_md, _i_time, NULL); + libvlc_media_instance_release(p_md); } } } @@ -959,57 +848,80 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev, long height = lprcBounds->bottom-lprcBounds->top; RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom }; - FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH)); - LPPICTURE pict = getPicture(); - if( NULL != pict ) + if( isUserMode() ) { - OLE_XSIZE_HIMETRIC picWidth; - OLE_YSIZE_HIMETRIC picHeight; - - pict->get_Width(&picWidth); - pict->get_Height(&picHeight); - - SIZEL picSize = { picWidth, picHeight }; - - if( NULL != hicTargetDev ) + /* VLC is in user mode, just draw background color */ + COLORREF colorref = RGB(0, 0, 0); + OleTranslateColor(_i_backcolor, (HPALETTE)GetStockObject(DEFAULT_PALETTE), &colorref); + if( colorref != RGB(0, 0, 0) ) { - DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1); + /* custom background */ + HBRUSH colorbrush = CreateSolidBrush(colorref); + FillRect(hdcDraw, &bounds, colorbrush); + DeleteObject((HANDLE)colorbrush); } - else if( NULL != (hicTargetDev = CreateDevDC(ptd)) ) + else { - DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1); - DeleteDC(hicTargetDev); + /* black background */ + FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(BLACK_BRUSH)); } + } + else + { + /* VLC is in design mode, draw the VLC logo */ + FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH)); - if( picSize.cx > width-4 ) - picSize.cx = width-4; - if( picSize.cy > height-4 ) - picSize.cy = height-4; + LPPICTURE pict = getPicture(); + if( NULL != pict ) + { + OLE_XSIZE_HIMETRIC picWidth; + OLE_YSIZE_HIMETRIC picHeight; - LONG dstX = lprcBounds->left+(width-picSize.cx)/2; - LONG dstY = lprcBounds->top+(height-picSize.cy)/2; + pict->get_Width(&picWidth); + pict->get_Height(&picHeight); - if( NULL != lprcWBounds ) - { - RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom }; - pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy, - 0L, picHeight, picWidth, -picHeight, &wBounds); - } - else - pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy, - 0L, picHeight, picWidth, -picHeight, NULL); + SIZEL picSize = { picWidth, picHeight }; - pict->Release(); - } + if( NULL != hicTargetDev ) + { + DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1); + } + else if( NULL != (hicTargetDev = CreateDevDC(ptd)) ) + { + DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1); + DeleteDC(hicTargetDev); + } + + if( picSize.cx > width-4 ) + picSize.cx = width-4; + if( picSize.cy > height-4 ) + picSize.cy = height-4; + + LONG dstX = lprcBounds->left+(width-picSize.cx)/2; + LONG dstY = lprcBounds->top+(height-picSize.cy)/2; + + if( NULL != lprcWBounds ) + { + RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom }; + pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy, + 0L, picHeight, picWidth, -picHeight, &wBounds); + } + else + pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy, + 0L, picHeight, picWidth, -picHeight, NULL); + + pict->Release(); + } - SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH)); + SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH)); - MoveToEx(hdcDraw, bounds.left, bounds.top, NULL); - LineTo(hdcDraw, bounds.left+width-1, bounds.top); - LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1); - LineTo(hdcDraw, bounds.left, bounds.top+height-1); - LineTo(hdcDraw, bounds.left, bounds.top); + MoveToEx(hdcDraw, bounds.left, bounds.top, NULL); + LineTo(hdcDraw, bounds.left+width-1, bounds.top); + LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1); + LineTo(hdcDraw, bounds.left, bounds.top+height-1); + LineTo(hdcDraw, bounds.left, bounds.top); + } } }; @@ -1017,8 +929,7 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect) { if( isVisible() ) { - /** if VLC is playing, it may not display any VIDEO content - ** hence, draw control logo*/ + /* if VLC is in design mode, draw control logo */ HDC hdcDraw = CreateCompatibleDC(hdc); if( NULL != hdcDraw ) { @@ -1061,52 +972,38 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect) void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) { RECT clipRect = *lprcClipRect; - RECT posRect = *lprcPosRect; //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); /* ** record keeping of control geometry within container */ - _posRect = posRect; - - /* - ** convert posRect & clipRect to match control viewport coordinates - */ - getViewportCoords(&posRect, &clipRect); + _posRect = *lprcPosRect; /* ** change in-place window geometry to match clipping region */ SetWindowPos(_inplacewnd, NULL, - clipRect.left, - clipRect.top, - clipRect.right-clipRect.left, - clipRect.bottom-clipRect.top, + lprcPosRect->left, + lprcPosRect->top, + lprcPosRect->right-lprcPosRect->left, + lprcPosRect->bottom-lprcPosRect->top, SWP_NOACTIVATE| SWP_NOCOPYBITS| SWP_NOZORDER| SWP_NOOWNERZORDER ); - /* - ** change video window geometry to match object bounds within clipping region - */ - SetWindowPos(_videownd, NULL, - posRect.left, - posRect.top, - posRect.right-posRect.left, - posRect.bottom-posRect.top, - SWP_NOACTIVATE| - SWP_NOCOPYBITS| - SWP_NOZORDER| - SWP_NOOWNERZORDER ); + /* change cliprect coordinates system relative to window bounding rect */ + OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top); + HRGN clipRgn = CreateRectRgnIndirect(&clipRect); + SetWindowRgn(_inplacewnd, clipRgn, FALSE); //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); if( isRunning() ) { libvlc_video_set_size(_p_libvlc, - posRect.right-posRect.left, - posRect.bottom-posRect.top, + lprcPosRect->right-lprcPosRect->left, + lprcPosRect->bottom-lprcPosRect->top, NULL ); } }; @@ -1118,24 +1015,23 @@ void VLCPlugin::freezeEvents(BOOL freeze) void VLCPlugin::firePropChangedEvent(DISPID dispid) { - vlcConnectionPointContainer->firePropChangedEvent(dispid); + vlcConnectionPointContainer->firePropChangedEvent(dispid); }; void VLCPlugin::fireOnPlayEvent(void) { DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs); + vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs); }; void VLCPlugin::fireOnPauseEvent(void) { DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs); + vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs); }; void VLCPlugin::fireOnStopEvent(void) { DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); + vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); }; -