Ignore:
Timestamp:
Sep 5, 2001, 2:14:25 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comdlg32/filedlgbrowser.c

    r5583 r6645  
     1/* $Id: filedlgbrowser.c,v 1.9 2001-09-05 12:12:01 bird Exp $ */
    12/*
    23 *  Implementation of IShellBrowser for the File Open common dialog
    3  * 
     4 *
    45 *
    56 */
     
    5960*   External Prototypes
    6061*/
    61 extern const char *FileOpenDlgInfosStr; 
     62extern const char *FileOpenDlgInfosStr;
    6263
    6364extern HRESULT          GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
     
    9192static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
    9293{
    93         TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
    94 
    95         switch (src->uType)
    96         {
    97           case STRRET_WSTR:
    98             lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
    99             COMDLG32_SHFree(src->u.pOleStr);
    100             break;
    101 
    102           case STRRET_CSTRA:
     94    TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
     95
     96    switch (src->uType)
     97    {
     98      case STRRET_WSTR:
     99        lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
     100        COMDLG32_SHFree(src->u.pOleStr);
     101        break;
     102
     103      case STRRET_CSTRA:
    103104            if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
    104105                ((LPWSTR)dest)[len-1] = 0;
    105             break;
    106 
    107           case STRRET_OFFSETA:
    108             if (pidl)
    109             {
     106        break;
     107
     108      case STRRET_OFFSETA:
     109        if (pidl)
     110        {
    110111                if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
    111112                                                 -1, (LPWSTR)dest, len ))
    112113                    ((LPWSTR)dest)[len-1] = 0;
    113             }
    114             break;
    115 
    116           default:
    117             FIXME("unknown type!\n");
    118             if (len)
    119             { *(LPWSTR)dest = '\0';
    120             }
    121             return(FALSE);
    122         }
    123         return S_OK;
     114        }
     115        break;
     116
     117      default:
     118        FIXME("unknown type!\n");
     119        if (len)
     120        { *(LPWSTR)dest = '\0';
     121        }
     122        return(FALSE);
     123    }
     124    return S_OK;
    124125}
    125126
    126127/*
    127  *      IShellBrowser
     128 *  IShellBrowser
    128129 */
    129  
     130
    130131/**************************************************************************
    131132*  IShellBrowserImpl_Construct
     
    158159*/
    159160HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
    160                                             REFIID riid, 
     161                                            REFIID riid,
    161162                                            LPVOID *ppvObj)
    162163{
     
    168169
    169170    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
    170     { *ppvObj = This; 
     171    { *ppvObj = This;
    171172    }
    172173    else if(IsEqualIID(riid, &IID_IOleWindow))  /*IOleWindow*/
     
    215216    TRACE("(%p)\n", This);
    216217
    217     if (!--(This->ref)) 
    218     { 
     218    if (!--(This->ref))
     219    {
    219220      HeapFree(GetProcessHeap(),0, This);
    220221      return 0;
     
    235236*
    236237*  Note : We will never be window less in the File Open dialog
    237 * 
    238 */
    239 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 
     238*
     239*/
     240HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
    240241                                           HWND * phwnd)
    241242{
     
    249250    *phwnd = This->hwndOwner;
    250251
    251     return (*phwnd) ? S_OK : E_UNEXPECTED; 
     252    return (*phwnd) ? S_OK : E_UNEXPECTED;
    252253
    253254}
     
    276277*  See Windows documentation on IShellBrowser::BrowseObject for more details
    277278*
    278 *  This function will override user specified flags and will always 
    279 *  use SBSP_DEFBROWSER and SBSP_DEFMODE. 
    280 */
    281 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 
    282                                               LPCITEMIDLIST pidl, 
     279*  This function will override user specified flags and will always
     280*  use SBSP_DEFBROWSER and SBSP_DEFMODE.
     281*/
     282HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     283                                              LPCITEMIDLIST pidl,
    283284                                              UINT wFlags)
    284285{
     
    301302    if(wFlags & SBSP_RELATIVE)
    302303    {
    303        
     304
    304305        /* SBSP_RELATIVE  A relative pidl (relative from the current folder) */
    305306        if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
     
    307308        {
    308309            ERR("bind to object failed\n");
    309             return hRes;
     310        return hRes;
    310311        }
    311312        /* create an absolute pidl */
     
    326327        psfTmp = GetShellFolderFromPidl(pidlTmp);
    327328    }
    328    
     329
    329330    if(!psfTmp)
    330331    {
     
    333334    }
    334335
    335     /* If the pidl to browse to is equal to the actual pidl ... 
     336    /* If the pidl to browse to is equal to the actual pidl ...
    336337       do nothing and pretend you did it*/
    337338    if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
    338339    {
    339340        IShellFolder_Release(psfTmp);
    340         COMDLG32_SHFree(pidlTmp);
     341    COMDLG32_SHFree(pidlTmp);
    341342        TRACE("keep current folder\n");
    342343        return NOERROR;
     
    395396
    396397    /* changes the tab order of the ListView to reflect the window's File Dialog */
    397     hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 
     398    hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
    398399    SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
    399400
     
    402403      SetFocus(fodInfos->ShellInfos.hwndView);
    403404
    404     return hRes; 
     405    return hRes;
    405406error:
    406407    ERR("Failed with error 0x%08lx\n", hRes);
     
    411412*  IShellBrowserImpl_EnableModelessSB
    412413*/
    413 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,   
     414HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
    414415                                              BOOL fEnable)
    415                                              
     416
    416417{
    417418    ICOM_THIS(IShellBrowserImpl, iface);
     
    426427*  IShellBrowserImpl_GetControlWindow
    427428*/
    428 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,   
    429                                               UINT id,   
     429HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
     430                                              UINT id,
    430431                                              HWND *lphwnd)
    431                                              
     432
    432433{
    433434    ICOM_THIS(IShellBrowserImpl, iface);
     
    442443*/
    443444HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
    444                                                 DWORD grfMode,   
     445                                                DWORD grfMode,
    445446                                                LPSTREAM *ppStrm)
    446                                              
     447
    447448{
    448449    ICOM_THIS(IShellBrowserImpl, iface);
     
    452453    /* Feature not implemented */
    453454    return E_NOTIMPL;
    454 }       
     455}
    455456/**************************************************************************
    456457*  IShellBrowserImpl_InsertMenusSB
     
    459460                                           HMENU hmenuShared,
    460461                                           LPOLEMENUGROUPWIDTHS lpMenuWidths)
    461                                              
     462
    462463{
    463464    ICOM_THIS(IShellBrowserImpl, iface);
     
    473474HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
    474475                                                IShellView *ppshv)
    475                                              
    476 {
    477     ICOM_THIS(IShellBrowserImpl, iface);
    478 
    479     TRACE("(%p)\n", This);
    480 
    481     /* Feature not implemented */
    482     return E_NOTIMPL;
    483 }   
     476
     477{
     478    ICOM_THIS(IShellBrowserImpl, iface);
     479
     480    TRACE("(%p)\n", This);
     481
     482    /* Feature not implemented */
     483    return E_NOTIMPL;
     484}
    484485/**************************************************************************
    485486*  IShellBrowserImpl_QueryActiveShellView
     
    487488HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
    488489                                                  IShellView **ppshv)
    489                                              
     490
    490491{
    491492    ICOM_THIS(IShellBrowserImpl, iface);
     
    503504    IShellView_AddRef(fodInfos->Shell.FOIShellView);
    504505    return NOERROR;
    505 }   
     506}
    506507/**************************************************************************
    507508*  IShellBrowserImpl_RemoveMenusSB
     
    509510HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
    510511                                           HMENU hmenuShared)
    511                                              
    512 {
    513     ICOM_THIS(IShellBrowserImpl, iface);
    514 
    515     TRACE("(%p)\n", This);
    516 
    517     /* Feature not implemented */
    518     return E_NOTIMPL;
    519 }   
     512
     513{
     514    ICOM_THIS(IShellBrowserImpl, iface);
     515
     516    TRACE("(%p)\n", This);
     517
     518    /* Feature not implemented */
     519    return E_NOTIMPL;
     520}
    520521/**************************************************************************
    521522*  IShellBrowserImpl_SendControlMsg
    522523*/
    523 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,   
    524                                             UINT id,   
    525                                             UINT uMsg,   
    526                                             WPARAM wParam,   
     524HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
     525                                            UINT id,
     526                                            UINT uMsg,
     527                                            WPARAM wParam,
    527528                                            LPARAM lParam,
    528529                                            LRESULT *pret)
    529                                              
     530
    530531{
    531532    ICOM_THIS(IShellBrowserImpl, iface);
    532533    LRESULT lres;
    533    
     534
    534535    TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
    535536
     
    538539      case FCW_TOOLBAR:
    539540        lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
    540         break;
     541    break;
    541542      default:
    542543        FIXME("ctrl id: %x\n", id);
     
    550551*/
    551552HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
    552                                        HMENU hmenuShared,   
     553                                       HMENU hmenuShared,
    553554                                       HOLEMENU holemenuReserved,
    554555                                       HWND hwndActiveObject)
    555                                              
    556 {
    557     ICOM_THIS(IShellBrowserImpl, iface);
    558 
    559     TRACE("(%p)\n", This);
    560 
    561     /* Feature not implemented */
    562     return E_NOTIMPL;
    563 }   
     556
     557{
     558    ICOM_THIS(IShellBrowserImpl, iface);
     559
     560    TRACE("(%p)\n", This);
     561
     562    /* Feature not implemented */
     563    return E_NOTIMPL;
     564}
    564565/**************************************************************************
    565566*  IShellBrowserImpl_SetStatusTextSB
     
    567568HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
    568569                                             LPCOLESTR lpszStatusText)
    569                                              
    570 {
    571     ICOM_THIS(IShellBrowserImpl, iface);
    572 
    573     TRACE("(%p)\n", This);
    574 
    575     /* Feature not implemented */
    576     return E_NOTIMPL;
    577 }   
     570
     571{
     572    ICOM_THIS(IShellBrowserImpl, iface);
     573
     574    TRACE("(%p)\n", This);
     575
     576    /* Feature not implemented */
     577    return E_NOTIMPL;
     578}
    578579/**************************************************************************
    579580*  IShellBrowserImpl_SetToolbarItems
    580581*/
    581582HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
    582                                              LPTBBUTTON lpButtons,   
    583                                              UINT nButtons,   
     583                                             LPTBBUTTON lpButtons,
     584                                             UINT nButtons,
    584585                                             UINT uFlags)
    585                                              
    586 {
    587     ICOM_THIS(IShellBrowserImpl, iface);
    588 
    589     TRACE("(%p)\n", This);
    590 
    591     /* Feature not implemented */
    592     return E_NOTIMPL;
    593 }   
     586
     587{
     588    ICOM_THIS(IShellBrowserImpl, iface);
     589
     590    TRACE("(%p)\n", This);
     591
     592    /* Feature not implemented */
     593    return E_NOTIMPL;
     594}
    594595/**************************************************************************
    595596*  IShellBrowserImpl_TranslateAcceleratorSB
    596597*/
    597598HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
    598                                                     LPMSG lpmsg,   
     599                                                    LPMSG lpmsg,
    599600                                                    WORD wID)
    600                                              
     601
    601602{
    602603    ICOM_THIS(IShellBrowserImpl, iface);
     
    644645*/
    645646HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
    646         ICommDlgBrowser *iface,
    647         REFIID riid,
    648         LPVOID *ppvObj)
     647    ICommDlgBrowser *iface,
     648    REFIID riid,
     649    LPVOID *ppvObj)
    649650{
    650651    _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
     
    693694    TRACE("(%p)\n", This);
    694695
    695     fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 
    696    
     696    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
     697
    697698    /* If the selected object is not a folder, send a IDOK command to parent window */
    698699    if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
     
    702703        ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
    703704        IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    704         if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
    705         {
     705    if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
     706    {
    706707          hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
    707         }
     708    }
    708709        else
    709         {
     710    {
    710711          /* Tell the dialog that the user selected a file */
    711           hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
    712         }
     712      hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
     713    }
    713714
    714715        /* Free memory used by pidl */
     
    737738        case CDBOSC_SETFOCUS:
    738739             /* FIXME: Reset the default button.
    739                 This should be taken care of by defdlg. If control
    740                 other than button receives focus the default button
    741                 should be restored. */
     740            This should be taken care of by defdlg. If control
     741            other than button receives focus the default button
     742            should be restored. */
    742743             SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
    743744
    744745            break;
    745         case CDBOSC_KILLFOCUS: 
    746             {
    747                 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    748                 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
    749                     SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
     746        case CDBOSC_KILLFOCUS:
     747        {
     748        FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
     749        if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
     750            SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
    750751            }
    751752            break;
     
    753754            return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
    754755        case CDBOSC_RENAME:
    755             /* nothing to do */
     756        /* nothing to do */
    756757            break;
    757758    }
    758759
    759     return NOERROR;     
     760    return NOERROR;
    760761}
    761762
     
    763764*  IShellBrowserImpl_ICommDlgBrowser_IncludeObject
    764765*/
    765 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 
     766HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
    766767                                                               IShellView * ppshv,
    767768                                                               LPCITEMIDLIST pidl)
     
    780781    ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
    781782    IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    782    
     783
    783784    if( (ulAttr & SFGAO_HIDDEN)                                         /* hidden */
    784785      | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
     
    786787
    787788    /* always include directorys and links */
    788     if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 
     789    if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
    789790        return S_OK;
    790791
     
    797798      if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
    798799      {
    799           if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
     800      if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
    800801          return S_OK;
    801802      }
     
    807808/**************************************************************************
    808809*  IShellBrowserImpl_ICommDlgBrowser_OnSelChange
    809 */ 
     810*/
    810811HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
    811812{
     
    816817    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    817818    TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
    818    
     819
    819820    /* release old selections */
    820821    if (fodInfos->Shell.FOIDataObject)
    821822      IDataObject_Release(fodInfos->Shell.FOIDataObject);
    822    
     823
    823824    /* get a new DataObject from the ShellView */
    824825    if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
    825826                              &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
    826827      return E_FAIL;
    827                                          
     828
    828829    FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
    829830
     
    856857*/
    857858HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
    858         IServiceProvider *iface,
    859         REFIID riid,
    860         LPVOID *ppvObj)
     859    IServiceProvider *iface,
     860    REFIID riid,
     861    LPVOID *ppvObj)
    861862{
    862863    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
     
    895896*
    896897* NOTES
    897 *  the w2k shellview asks for 
     898*  the w2k shellview asks for
    898899*   guidService = SID_STopLevelBrowser
    899900*   riid = IShellBrowser
     
    904905
    905906HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
    906         IServiceProvider * iface,
    907         REFGUID guidService,
    908         REFIID riid,
    909         void** ppv)
     907    IServiceProvider * iface,
     908    REFGUID guidService,
     909    REFIID riid,
     910    void** ppv)
    910911{
    911912    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
Note: See TracChangeset for help on using the changeset viewer.