2 * Implementation of IShellBrowser for the File Open common dialog
9 #include "filedlgbrowser.h"
14 #include "wine/obj_dataobject.h"
15 #include "debugtools.h"
17 #include "wine/undocshell.h"
19 DEFAULT_DEBUG_CHANNEL(commdlg)
21 #define SETDefFormatEtc(fe,cf,med) \
24 (fe).dwAspect = DVASPECT_CONTENT; \
31 /**************************************************************************
34 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
36 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
38 IShellBrowserImpl_QueryInterface,
39 IShellBrowserImpl_AddRef,
40 IShellBrowserImpl_Release,
42 IShellBrowserImpl_GetWindow,
43 IShellBrowserImpl_ContextSensitiveHelp,
45 IShellBrowserImpl_InsertMenusSB,
46 IShellBrowserImpl_SetMenuSB,
47 IShellBrowserImpl_RemoveMenusSB,
48 IShellBrowserImpl_SetStatusTextSB,
49 IShellBrowserImpl_EnableModelessSB,
50 IShellBrowserImpl_TranslateAcceleratorSB,
51 IShellBrowserImpl_BrowseObject,
52 IShellBrowserImpl_GetViewStateStream,
53 IShellBrowserImpl_GetControlWindow,
54 IShellBrowserImpl_SendControlMsg,
55 IShellBrowserImpl_QueryActiveShellView,
56 IShellBrowserImpl_OnViewWindowActive,
57 IShellBrowserImpl_SetToolbarItems
60 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
62 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
64 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
65 IShellBrowserImpl_ICommDlgBrowser_AddRef,
66 IShellBrowserImpl_ICommDlgBrowser_Release,
68 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
69 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
70 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
74 /**************************************************************************
78 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
80 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
83 /**************************************************************************
86 extern const char *FileOpenDlgInfosStr;
88 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
89 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
90 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
91 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
92 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
94 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
95 LPITEMIDLIST pidlCurrentFolder,
98 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
99 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
100 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
103 /**************************************************************************
104 * IShellBrowserImpl_Construct
106 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
108 IShellBrowserImpl *sb;
109 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
111 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
113 /* Initialisation of the member variables */
115 sb->hwndOwner = hwndOwner;
117 /* Initialisation of the vTables */
118 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
119 sb->lpVtbl2 = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
121 COMDLG32_SHGetSpecialFolderLocation(hwndOwner,
123 &fodInfos->ShellInfos.pidlAbsCurrent);
127 return (IShellBrowser *) sb;
130 /**************************************************************************
133 * The INTERFACE of the IShellBrowser object
141 /***************************************************************************
142 * IShellBrowserImpl_QueryInterface
144 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
148 ICOM_THIS(IShellBrowserImpl, iface);
150 TRACE("(%p)\n", This);
154 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
157 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
158 { *ppvObj = (IOleWindow*)This;
161 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
162 { *ppvObj = (IShellBrowser*)This;
165 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
166 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtbl2);
170 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
173 return E_NOINTERFACE;
176 /**************************************************************************
177 * IShellBrowser::AddRef
179 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
181 ICOM_THIS(IShellBrowserImpl, iface);
183 TRACE("(%p)\n", This);
185 return ++(This->ref);
188 /**************************************************************************
189 * IShellBrowserImpl_Release
191 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
193 ICOM_THIS(IShellBrowserImpl, iface);
195 TRACE("(%p)\n", This);
199 COMDLG32_SHFree(This);
209 /**************************************************************************
210 * IShellBrowserImpl_GetWindow (IOleWindow)
212 * Inherited from IOleWindow::GetWindow
214 * See Windows documentation for more details
216 * Note : We will never be window less in the File Open dialog
219 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
222 ICOM_THIS(IShellBrowserImpl, iface);
224 TRACE("(%p)\n", This);
229 *phwnd = This->hwndOwner;
231 return (*phwnd) ? S_OK : E_UNEXPECTED;
235 /**************************************************************************
236 * IShellBrowserImpl_ContextSensitiveHelp
238 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
241 ICOM_THIS(IShellBrowserImpl, iface);
243 TRACE("(%p)\n", This);
245 /* Feature not implemented */
253 /**************************************************************************
254 * IShellBrowserImpl_BrowseObject
256 * See Windows documentation on IShellBrowser::BrowseObject for more details
258 * This function will override user specified flags and will always
259 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
261 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
266 IShellFolder *psfTmp;
268 FileOpenDlgInfos *fodInfos;
269 LPITEMIDLIST pidlTmp;
271 ICOM_THIS(IShellBrowserImpl, iface);
273 TRACE("(%p)\n", This);
275 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
277 /* Format the pidl according to its parameter's category */
278 if(wFlags & SBSP_RELATIVE)
281 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
282 hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
291 /* create an absolute pidl */
292 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
296 else if(wFlags & SBSP_PARENT)
298 /* Browse the parent folder (ignores the pidl) */
300 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
301 psfTmp = GetShellFolderFromPidl(pidlTmp);
306 /* An absolute pidl (relative from the desktop) */
307 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
308 psfTmp = GetShellFolderFromPidl(pidlTmp);
312 /* Retrieve the IShellFolder interface of the pidl specified folder */
316 /* If the pidl to browse to is equal to the actual pidl ...
317 do nothing and pretend you did it*/
318 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
320 IShellFolder_Release(psfTmp);
321 COMDLG32_SHFree(pidlTmp);
325 /* Release the current fodInfos->Shell.FOIShellFolder and update its value */
326 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
327 fodInfos->Shell.FOIShellFolder = psfTmp;
329 /* Create the associated view */
330 if(SUCCEEDED(hRes = IShellFolder_CreateViewObject(psfTmp,
331 fodInfos->ShellInfos.hwndOwner,
337 /* Get the foldersettings from the old view */
338 if(fodInfos->Shell.FOIShellView)
340 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView,
341 &fodInfos->ShellInfos.folderSettings);
344 /* Create the window */
345 if(SUCCEEDED(hRes = IShellView_CreateViewWindow(psvTmp,
347 &fodInfos->ShellInfos.folderSettings,
348 fodInfos->Shell.FOIShellBrowser,
349 &fodInfos->ShellInfos.rectView,
352 /* Fit the created view in the appropriate RECT */
354 fodInfos->ShellInfos.rectView.left,
355 fodInfos->ShellInfos.rectView.top,
356 fodInfos->ShellInfos.rectView.right-fodInfos->ShellInfos.rectView.left,
357 fodInfos->ShellInfos.rectView.bottom-fodInfos->ShellInfos.rectView.top,
360 /* Select the new folder in the Look In combo box of the Open file dialog */
362 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,pidlTmp);
364 /* Release old pidlAbsCurrent memory and update its value */
365 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
366 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
368 /* Release the current fodInfos->Shell.FOIShellView and update its value */
369 if(fodInfos->Shell.FOIShellView)
371 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
372 IShellView_Release(fodInfos->Shell.FOIShellView);
375 ShowWindow(fodInfos->ShellInfos.hwndView,SW_HIDE);
377 fodInfos->Shell.FOIShellView = psvTmp;
379 fodInfos->ShellInfos.hwndView = hwndView;
381 /* changes the tab order of the ListView to reflect the window's File Dialog */
382 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
383 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
390 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
394 /**************************************************************************
395 * IShellBrowserImpl_EnableModelessSB
397 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
401 ICOM_THIS(IShellBrowserImpl, iface);
403 TRACE("(%p)\n", This);
405 /* Feature not implemented */
409 /**************************************************************************
410 * IShellBrowserImpl_GetControlWindow
412 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
417 ICOM_THIS(IShellBrowserImpl, iface);
419 TRACE("(%p)\n", This);
421 /* Feature not implemented */
424 /**************************************************************************
425 * IShellBrowserImpl_GetViewStateStream
427 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
432 ICOM_THIS(IShellBrowserImpl, iface);
434 TRACE("(%p)\n", This);
436 /* Feature not implemented */
439 /**************************************************************************
440 * IShellBrowserImpl_InsertMenusSB
442 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
444 LPOLEMENUGROUPWIDTHS lpMenuWidths)
447 ICOM_THIS(IShellBrowserImpl, iface);
449 TRACE("(%p)\n", This);
451 /* Feature not implemented */
454 /**************************************************************************
455 * IShellBrowserImpl_OnViewWindowActive
457 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
461 ICOM_THIS(IShellBrowserImpl, iface);
463 TRACE("(%p)\n", This);
465 /* Feature not implemented */
468 /**************************************************************************
469 * IShellBrowserImpl_QueryActiveShellView
471 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
475 ICOM_THIS(IShellBrowserImpl, iface);
477 FileOpenDlgInfos *fodInfos;
479 TRACE("(%p)\n", This);
481 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
483 if(!(*ppshv = fodInfos->Shell.FOIShellView))
487 IShellView_AddRef(fodInfos->Shell.FOIShellView);
490 /**************************************************************************
491 * IShellBrowserImpl_RemoveMenusSB
493 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
497 ICOM_THIS(IShellBrowserImpl, iface);
499 TRACE("(%p)\n", This);
501 /* Feature not implemented */
504 /**************************************************************************
505 * IShellBrowserImpl_SendControlMsg
507 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
515 ICOM_THIS(IShellBrowserImpl, iface);
518 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
523 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
526 FIXME("ctrl id: %x\n", id);
529 if (pret) *pret = lres;
532 /**************************************************************************
533 * IShellBrowserImpl_SetMenuSB
535 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
537 HOLEMENU holemenuReserved,
538 HWND hwndActiveObject)
541 ICOM_THIS(IShellBrowserImpl, iface);
543 TRACE("(%p)\n", This);
545 /* Feature not implemented */
548 /**************************************************************************
549 * IShellBrowserImpl_SetStatusTextSB
551 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
552 LPCOLESTR lpszStatusText)
555 ICOM_THIS(IShellBrowserImpl, iface);
557 TRACE("(%p)\n", This);
559 /* Feature not implemented */
562 /**************************************************************************
563 * IShellBrowserImpl_SetToolbarItems
565 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
566 LPTBBUTTON lpButtons,
571 ICOM_THIS(IShellBrowserImpl, iface);
573 TRACE("(%p)\n", This);
575 /* Feature not implemented */
578 /**************************************************************************
579 * IShellBrowserImpl_TranslateAcceleratorSB
581 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
586 ICOM_THIS(IShellBrowserImpl, iface);
588 TRACE("(%p)\n", This);
590 /* Feature not implemented */
598 /***************************************************************************
599 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
601 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(ICommDlgBrowser *iface,
605 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
607 TRACE("(%p)\n", This);
609 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
612 /**************************************************************************
613 * IShellBrowserImpl_ICommDlgBrowser_AddRef
615 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
617 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
619 TRACE("(%p)\n", This);
621 return IShellBrowserImpl_AddRef(This);
624 /**************************************************************************
625 * IShellBrowserImpl_ICommDlgBrowser_Release
627 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
629 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
631 TRACE("(%p)\n", This);
633 return IShellBrowserImpl_Release(This);
635 /**************************************************************************
636 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
638 * Called when a user double-clicks in the view or presses the ENTER key
640 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
644 FileOpenDlgInfos *fodInfos;
646 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
648 TRACE("(%p)\n", This);
650 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
652 /* If the selected object is not a folder, send a IDOK command to parent window */
653 if((pidl = GetSelectedPidl(ppshv)))
657 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
658 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
660 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
661 /* Tell the dialog that the user selected a file */
664 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
667 /* Free memory used by pidl */
668 COMDLG32_SHFree((LPVOID)pidl);
676 /**************************************************************************
677 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
679 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
684 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
686 TRACE("(%p)\n", This);
690 case CDBOSC_SETFOCUS:
692 case CDBOSC_KILLFOCUS:
694 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
695 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
696 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
699 case CDBOSC_SELCHANGE:
700 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
708 /* copied from shell32 to avoid linking to it */
709 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
711 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
716 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
717 COMDLG32_SHFree(src->u.pOleStr);
721 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
727 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
732 FIXME("unknown type!\n");
734 { *(LPSTR)dest = '\0';
740 /**************************************************************************
741 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
743 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
747 FileOpenDlgInfos *fodInfos;
750 WCHAR szPathW[MAX_PATH];
752 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
754 TRACE("(%p)\n", This);
756 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
758 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
759 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
762 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
763 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
765 /* always include directorys and links */
766 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
768 /* Check if there is a mask to apply if not */
769 if(!fodInfos->ShellInfos.lpstrCurrentFilter ||
770 !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
773 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_FORPARSING, &str)))
774 { if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
776 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
784 /**************************************************************************
785 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
787 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
789 FileOpenDlgInfos *fodInfos;
793 char lpstrFileList[MAX_PATH];
794 char lpstrTemp[MAX_PATH];
795 LPSTR lpstrCurrFile = lpstrFileList;
796 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
798 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
799 TRACE("(%p)\n", This);
801 nFileSelected = GetNumSelected( fodInfos->Shell.FOIShellView );
802 /* Count how many files we have */
803 for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
805 LPITEMIDLIST pidlSelection;
806 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
808 /* get the file selected */
809 EnumSelectedPidls( fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection );
810 IShellFolder_GetAttributesOf( fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr );
815 COMDLG32_SHFree( (LPVOID) pidlSelection );
818 /* Generate the string for the edit control */
819 ZeroMemory(lpstrFileList, MAX_PATH);
822 for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
824 LPITEMIDLIST pidlSelection;
825 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
827 memset( lpstrTemp, 0x0, MAX_PATH * sizeof(char) );
829 /* get the file selected */
830 EnumSelectedPidls( fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection );
831 GetName( fodInfos->Shell.FOIShellFolder, pidlSelection, SHGDN_NORMAL, lpstrTemp );
833 IShellFolder_GetAttributesOf( fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr );
835 if ( uAttr & SFGAO_FOLDER ) /* Ignore folders */
838 if (nFiles > 1) /* Quote files if we have more than one */
840 *lpstrCurrFile++ = '\"';
841 lstrcpyA( lpstrCurrFile, lpstrTemp );
842 lpstrCurrFile += lstrlenA( lpstrTemp );
843 lstrcpyA( lpstrCurrFile, "\" " );
848 lstrcpyA( lpstrCurrFile, lpstrTemp );
851 COMDLG32_SHFree( (LPVOID) pidlSelection );
854 SetWindowTextA(fodInfos->DlgInfos.hwndFileName,lpstrFileList);
855 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
856 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
858 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Open");
860 fodInfos->DlgInfos.dwDlgProp |= FODPROP_USEVIEW;
861 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
865 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
866 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
868 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
870 return nFileSelected ? S_OK : E_FAIL;
873 /***********************************************************************
876 * Return the pidl of the first selected item in the view
878 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv)
881 IDataObject *doSelected;
882 LPITEMIDLIST pidlSelected = NULL;
884 TRACE("sv=%p\n", ppshv);
886 /* Get an IDataObject from the view */
887 if(SUCCEEDED(IShellView_GetItemObject(ppshv,
890 (LPVOID *)&doSelected)))
895 /* Set the FORMATETC structure*/
896 SETDefFormatEtc(formatetc,
897 RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
900 /* Get the pidl from IDataObject */
901 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
903 LPIDA cida = GlobalLock(medium.u.hGlobal);
904 TRACE("cida=%p\n", cida);
905 pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[1]]));
907 if(medium.pUnkForRelease)
908 IUnknown_Release(medium.pUnkForRelease);
911 GlobalUnlock(medium.u.hGlobal);
912 GlobalFree(medium.u.hGlobal);
915 IDataObject_Release(doSelected);
922 /***********************************************************************
925 * Return the pidl(s) of the selected item(s) in the view.
928 BOOL EnumSelectedPidls( IShellView *ppshv, /*[in]*/
929 UINT nPidlIndex, /*[in]*/
930 LPITEMIDLIST *pidlSelected /*[out]*/ )
933 IDataObject *doSelected;
936 /* Get an IDataObject from the view */
937 if(SUCCEEDED(IShellView_GetItemObject(ppshv,
940 (LPVOID *)&doSelected)))
945 /* Set the FORMATETC structure*/
946 SETDefFormatEtc(formatetc,
947 RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
950 /* Get the pidls from IDataObject */
951 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
953 LPIDA cida = GlobalLock(medium.u.hGlobal);
954 if(nPidlIndex < cida->cidl)
956 *pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex + 1]]));
963 if(medium.pUnkForRelease)
965 IUnknown_Release(medium.pUnkForRelease);
969 GlobalUnlock(medium.u.hGlobal);
970 GlobalFree(medium.u.hGlobal);
973 IDataObject_Release(doSelected);
979 /***********************************************************************
982 * Return the number of selected items in the view.
985 UINT GetNumSelected( IShellView *ppshv )
987 IDataObject *doSelected;
990 /* Get an IDataObject from the view */
991 if(SUCCEEDED(IShellView_GetItemObject(ppshv,
994 (LPVOID *)&doSelected)))
999 /* Set the FORMATETC structure*/
1000 SETDefFormatEtc(formatetc,
1001 RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
1004 /* Get the pidls from IDataObject */
1005 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
1007 LPIDA cida = GlobalLock(medium.u.hGlobal);
1008 retVal = cida->cidl;
1010 if(medium.pUnkForRelease)
1012 IUnknown_Release(medium.pUnkForRelease);
1016 GlobalUnlock(medium.u.hGlobal);
1017 GlobalFree(medium.u.hGlobal);
1020 IDataObject_Release(doSelected);