Changeset da4dc63b33a3cbffa38513107882a05f2043d17c

Show
Ignore:
Timestamp:
27/06/05 13:41:16 (3 years ago)
Author:
Damien Fouilleul <damienf@videolan.org>
git-committer:
Damien Fouilleul <damienf@videolan.org> 1119872476 +0000
git-parent:

[da5c4157bbcaf84ab20b452483fbe470ea2654b4]

git-author:
Damien Fouilleul <damienf@videolan.org> 1119872476 +0000
Message:

all: clean-up, bug fixes so that plugin is now working correctly with Visual Basic 6 (which I have tested) and hopefully should also work with .NET (which I havent't tested).

Outstanding issue: the control properties are not persisted

vlc16x16.bmp: toolbar icon for VLC plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • activex/Makefile.am

    rb9057a6 rda4dc63  
    5353    axvlc.tlb \ 
    5454    inplace.bmp \ 
     55    vlc16x16.bmp \ 
    5556    test.html \ 
    5657    $(NULL) 
  • activex/axvlc_rc.rc

    rec19e63 rda4dc63  
    99#define UGLY_KLUDGE( z ) #z 
    1010 
     111 BITMAP "vlc16x16.bmp" 
    11121 VERSIONINFO 
    1213FILETYPE 1 
  • activex/main.cpp

    r83974ce rda4dc63  
    187187        RegCloseKey(hSubKey); 
    188188 
     189        // ToolboxBitmap32 key value 
     190        hSubKey = keyCreate(hClassKey, TEXT("ToolboxBitmap32")); 
     191        strcpy(DllPath+DllPathLen, ",1"); 
     192        RegSetValueEx(hSubKey, NULL, 0, REG_SZ, 
     193                (const BYTE*)DllPath, DllPathLen+2); 
     194        DllPath[DllPathLen] = '\0'; 
     195        RegCloseKey(hSubKey); 
     196 
    189197#ifdef BUILD_LOCALSERVER 
    190198        // LocalServer32 key value 
  • activex/oleobject.cpp

    r1b75d79 rda4dc63  
    5757                                    LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect) 
    5858{ 
    59     if( 0 != lIndex ) 
    60         return DV_E_LINDEX; 
    61  
    6259    switch( iVerb ) 
    6360    { 
     
    105102        { 
    106103            if( S_OK != p_inPlaceSite->CanInPlaceActivate() ) 
     104            { 
    107105                return OLEOBJ_S_CANNOT_DOVERB_NOW; 
     106            } 
    108107 
    109108            LPOLEINPLACEFRAME p_inPlaceFrame; 
     
    129128        } 
    130129        else if( NULL == hwndParent ) 
     130        { 
    131131            return OLEOBJ_S_INVALIDHWND; 
     132        } 
    132133 
    133134        if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) ) 
     
    294295STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite) 
    295296{ 
    296     if( NULL != _p_clientsite ) 
    297         _p_clientsite->Release();  
    298297  
    299298    if( NULL != pClientSite ) 
     
    313312        } 
    314313    } 
     314 
     315    if( NULL != _p_clientsite ) 
     316        _p_clientsite->Release(); 
     317 
    315318    _p_clientsite = pClientSite; 
    316319    _p_instance->onClientSiteChanged(pClientSite); 
     320 
    317321    return S_OK; 
    318322}; 
     
    338342            if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) 
    339343            { 
    340                 LPOLECONTROLSITE p_controlSite; 
    341                 RECT posRect = _p_instance->getPosRect(); 
    342  
    343                 if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleControlSite, (void**)&p_controlSite)) ) 
     344                HWND hwnd; 
     345 
     346                if( SUCCEEDED(p_inPlaceSite->GetWindow(&hwnd)) ) 
    344347                { 
    345                     // use HIMETRIC to container transform 
    346                     POINTL extent = { pSizel->cx, pSizel->cy }; 
    347                     POINTF container; 
    348                     if( SUCCEEDED(p_controlSite->TransformCoords(&extent, 
    349                                     &container, XFORMCOORDS_SIZE|XFORMCOORDS_HIMETRICTOCONTAINER)) ) 
    350                     { 
    351                         posRect.right  = ((LONG)container.x)+posRect.left; 
    352                         posRect.bottom = ((LONG)container.y)+posRect.top; 
    353                     } 
    354                     p_controlSite->Release(); 
    355                 } 
    356                 else { 
    357                     // use HIMETRIC to display transform  
    358                     HDC hDC = CreateDevDC(NULL); 
     348                    // use HIMETRIC to pixel transform  
     349                    RECT posRect = _p_instance->getPosRect(); 
     350                    HDC hDC = GetDC(hwnd); 
    359351                    posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left; 
    360352                    posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top; 
    361353                    DeleteDC(hDC); 
     354                    p_inPlaceSite->OnPosRectChange(&posRect); 
    362355                } 
    363                 p_inPlaceSite->OnPosRectChange(&posRect); 
    364356                p_inPlaceSite->Release(); 
    365357            } 
  • activex/persistpropbag.cpp

    r1b75d79 rda4dc63  
    4141STDMETHODIMP VLCPersistPropertyBag::InitNew(void) 
    4242{ 
    43     return _p_instance->onInit(TRUE); 
     43    return _p_instance->onInit(); 
    4444}; 
    4545 
     
    4949        return E_POINTER; 
    5050 
    51     HRESULT hr = _p_instance->onInit(FALSE); 
     51    HRESULT hr = _p_instance->onInit(); 
    5252    if( FAILED(hr) ) 
    5353        return hr; 
  • activex/persiststorage.cpp

    r1591dec rda4dc63  
    4646        return E_POINTER; 
    4747 
    48     return _p_instance->onInit(TRUE); 
     48    return _p_instance->onInit(); 
    4949}; 
    5050 
     
    5454        return E_POINTER; 
    5555 
    56     return _p_instance->onInit(TRUE); 
     56    return _p_instance->onInit(); 
    5757}; 
    5858 
  • activex/persiststreaminit.cpp

    r1591dec rda4dc63  
    3838STDMETHODIMP VLCPersistStreamInit::InitNew(void) 
    3939{ 
    40     return _p_instance->onInit(TRUE); 
     40    return _p_instance->onInit(); 
    4141}; 
    4242 
     
    4646        return E_POINTER; 
    4747 
    48     return _p_instance->onInit(TRUE); 
     48    return _p_instance->onInit(); 
    4949}; 
    5050 
  • activex/plugin.cpp

    rfd5297c rda4dc63  
    3535#include "vlccontrol.h" 
    3636#include "viewobject.h" 
     37#include "dataobject.h" 
    3738 
    3839#include "utils.h" 
     
    511512}; 
    512513 
    513 HRESULT VLCPlugin::onInit(BOOL isNew
     514HRESULT VLCPlugin::onInit(void
    514515{ 
    515516    if( 0 == _i_vlc ) 
     
    550551            return E_FAIL; 
    551552        } 
    552  
    553         if( isNew ) 
    554         { 
    555             /* 
    556             ** object has fully initialized, 
    557             ** try to activate in place if container is ready 
    558             */ 
    559             LPOLECLIENTSITE pActiveSite; 
    560  
    561             if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) ) 
    562             { 
    563                 vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL); 
    564                 pActiveSite->Release(); 
    565             } 
    566         } 
    567553        return S_OK; 
    568554    } 
     
    572558HRESULT VLCPlugin::onLoad(void) 
    573559{ 
    574     /* 
    575     ** object has fully initialized, 
    576     ** try to activate in place if container is ready 
    577     */ 
    578     LPOLECLIENTSITE pActiveSite; 
    579  
    580     if( SUCCEEDED(vlcOleObject->GetClientSite(&pActiveSite)) && (NULL != pActiveSite) ) 
    581     { 
    582         vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL); 
    583         pActiveSite->Release(); 
     560    if( _b_mute ) 
     561        VLC_VolumeMute(_i_vlc); 
     562 
     563    if( NULL != _psz_src ) 
     564    { 
     565        // add default target to playlist 
     566        char *cOptions[1]; 
     567        int  cOptionsCount = 0; 
     568 
     569        if( _b_loopmode ) 
     570        { 
     571            cOptions[cOptionsCount++] = "loop"; 
     572        } 
     573        VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END); 
    584574    } 
    585575    return S_OK; 
     
    695685    VLC_VariableSet(_i_vlc, "drawable", val); 
    696686 
    697     if( NULL != _psz_src ) 
    698     { 
    699         // add target to playlist 
    700         char *cOptions[1]; 
    701         int  cOptionsCount = 0; 
    702  
    703         if( _b_loopmode ) 
    704         { 
    705             cOptions[cOptionsCount++] = "loop"; 
    706         } 
    707         VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END); 
    708  
    709         if( _b_autostart ) 
    710         { 
    711             VLC_Play(_i_vlc); 
    712             fireOnPlayEvent(); 
    713         } 
     687    if( _b_autostart & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) ) 
     688    { 
     689        VLC_Play(_i_vlc); 
     690        fireOnPlayEvent(); 
    714691    } 
    715692    return S_OK; 
     
    750727void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr) 
    751728{ 
    752     /* 
    753     ** if VLC is playing, it may not display any VIDEO content  
    754     ** hence, draw control logo 
    755     */  
    756     int width = bounds.right-bounds.left; 
    757     int height = bounds.bottom-bounds.top; 
    758  
    759     HBITMAP pict = _p_class->getInPlacePict(); 
    760     if( NULL != pict ) 
    761     { 
    762         HDC hdcPict = CreateCompatibleDC(hdc); 
    763         if( NULL != hdcPict ) 
    764         { 
    765             BITMAP bm; 
    766             if( GetObject(pict, sizeof(BITMAPINFO), &bm) ) 
     729    if( getVisible() ) 
     730    { 
     731        /* 
     732        ** if VLC is playing, it may not display any VIDEO content  
     733        ** hence, draw control logo 
     734        */  
     735        int width = bounds.right-bounds.left; 
     736        int height = bounds.bottom-bounds.top; 
     737 
     738        HBITMAP pict = _p_class->getInPlacePict(); 
     739        if( NULL != pict ) 
     740        { 
     741            HDC hdcPict = CreateCompatibleDC(hdc); 
     742            if( NULL != hdcPict ) 
    767743            { 
    768                 int dstWidth = bm.bmWidth; 
    769                 if( dstWidth > width-4 ) 
    770                     dstWidth = width-4; 
    771  
    772                 int dstHeight = bm.bmHeight; 
    773                 if( dstHeight > height-4 ) 
    774                     dstHeight = height-4; 
    775  
    776                 int dstX = bounds.left+(width-dstWidth)/2; 
    777                 int dstY = bounds.top+(height-dstHeight)/2; 
    778  
    779                 SelectObject(hdcPict, pict); 
    780                 StretchBlt(hdc, dstX, dstY, dstWidth, dstHeight, 
    781                         hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); 
    782                 DeleteDC(hdcPict); 
    783                 ExcludeClipRect(hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY); 
     744                BITMAP bm; 
     745                if( GetObject(pict, sizeof(BITMAPINFO), &bm) ) 
     746                { 
     747                    int dstWidth = bm.bmWidth; 
     748                    if( dstWidth > width-4 ) 
     749                        dstWidth = width-4; 
     750 
     751                    int dstHeight = bm.bmHeight; 
     752                    if( dstHeight > height-4 ) 
     753                        dstHeight = height-4; 
     754 
     755                    int dstX = bounds.left+(width-dstWidth)/2; 
     756                    int dstY = bounds.top+(height-dstHeight)/2; 
     757 
     758                    SelectObject(hdcPict, pict); 
     759                    StretchBlt(hdc, dstX, dstY, dstWidth, dstHeight, 
     760                            hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); 
     761                    DeleteDC(hdcPict); 
     762                    ExcludeClipRect(hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY); 
     763                } 
    784764            } 
    785765        } 
    786     } 
    787  
    788     FillRect(hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH)); 
    789     SelectObject(hdc, GetStockObject(BLACK_BRUSH)); 
    790  
    791     MoveToEx(hdc, bounds.left, bounds.top, NULL); 
    792     LineTo(hdc, bounds.left+width-1, bounds.top); 
    793     LineTo(hdc, bounds.left+width-1, bounds.top+height-1); 
    794     LineTo(hdc, bounds.left, bounds.top+height-1); 
    795     LineTo(hdc, bounds.left, bounds.top); 
     766 
     767        FillRect(hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH)); 
     768        SelectObject(hdc, GetStockObject(BLACK_BRUSH)); 
     769 
     770        MoveToEx(hdc, bounds.left, bounds.top, NULL); 
     771        LineTo(hdc, bounds.left+width-1, bounds.top); 
     772        LineTo(hdc, bounds.left+width-1, bounds.top+height-1); 
     773        LineTo(hdc, bounds.left, bounds.top+height-1); 
     774        LineTo(hdc, bounds.left, bounds.top); 
     775    } 
    796776}; 
    797777 
     
    802782 
    803783    /* 
     784    ** tell container that previous area needs redrawing 
     785    */ 
     786 
     787    InvalidateRect(GetParent(_inplacewnd), &_posRect, TRUE); 
     788 
     789    /* 
    804790    ** record keeping of control geometry within container 
    805     */  
     791    */ 
     792 
    806793    _posRect = posRect; 
    807794 
     
    831818            FALSE); 
    832819 
    833  
    834820    /* 
    835821    ** force a full refresh of control content 
  • activex/plugin.h

    r1b75d79 rda4dc63  
    8585    REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; }; 
    8686 
    87     HRESULT onInit(BOOL isNew); 
     87    HRESULT onInit(void); 
    8888    HRESULT onLoad(void); 
    8989    HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite); 
     
    103103    int  getVLCObject(void) { return _i_vlc; }; 
    104104 
    105     // control properties 
     105    // persistent control properties, may be overriden by HTML & javascript 
    106106    void setSourceURL(const char *url) { _psz_src = strdup(url); }; 
    107107    void setAutoStart(BOOL autostart) { _b_autostart = autostart; }; 
    108108    void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; }; 
    109     void setMute(BOOL mute) { 
    110         if( mute && _i_vlc ) 
    111         { 
    112             VLC_VolumeMute(_i_vlc); 
    113         } 
    114     }; 
     109    void setMute(BOOL mute) { _b_mute = mute; }; 
    115110    void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; }; 
    116111    void setVisible(BOOL fVisible); 
    117112    BOOL getVisible(void) { return _b_visible; }; 
    118  
    119113     
    120114    // container events 
     
    168162    BOOL _b_loopmode; 
    169163    BOOL _b_visible; 
     164    BOOL _b_mute; 
    170165    BOOL _b_sendevents; 
    171166    int  _i_vlc; 
  • activex/utils.h

    r1b75d79 rda4dc63  
    6161    // cloning is implemented by subclasses and must use copy constructor 
    6262    //STDMETHODIMP Clone(VLCEnum<T> **); 
    63     // cloning is implemented by subclasses and must use copy constructor 
    6463 
    6564    typedef void (*retainer)(T); 
  • activex/viewobject.cpp

    r83974ce rda4dc63  
    3434    if( dwAspect & DVASPECT_CONTENT ) 
    3535    { 
    36         if( _p_instance->getVisible() ) 
    37         { 
    38             RECT bounds; 
    39             bounds.left   = lprcBounds->left; 
    40             bounds.top    = lprcBounds->top; 
    41             bounds.right  = lprcBounds->right; 
    42             bounds.bottom = lprcBounds->bottom; 
    43             _p_instance->onPaint(hdcDraw, bounds, bounds); 
    44         } 
     36        RECT bounds; 
     37        bounds.left   = lprcBounds->left; 
     38        bounds.top    = lprcBounds->top; 
     39        bounds.right  = lprcBounds->right; 
     40        bounds.bottom = lprcBounds->bottom; 
     41        _p_instance->onPaint(hdcDraw, bounds, bounds); 
    4542        return S_OK; 
    4643    } 
     
    8582        LPADVISESINK pAdvSink) 
    8683{ 
    87     _dwAspect = dwAspect; 
    88     _advf = advf; 
     84 
     85    if( NULL != pAdvSink ) 
     86        pAdvSink->AddRef(); 
     87 
    8988    if( NULL != _pAdvSink ) 
    9089        _pAdvSink->Release(); 
    9190 
     91    _dwAspect = dwAspect; 
     92    _advf = advf; 
    9293    _pAdvSink = pAdvSink; 
    93     if( NULL != pAdvSink ) 
     94 
     95    if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) ) 
    9496    { 
    95         pAdvSink->AddRef(); 
     97        _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1); 
     98    } 
    9699 
    97         if( dwAspect & DVASPECT_CONTENT ) 
    98         { 
    99             pAdvSink->OnViewChange(DVASPECT_CONTENT, -1); 
    100         } 
    101     } 
    102100    return S_OK; 
    103101};