Implement InternalExtractIcon by calling PrivateExtractIcons instead
[wine/testsucceed.git] / dlls / commdlg / filedlgbrowser.c
blob3549c1180a441c7e2f422d675da3bd38fe26b3df
1 /*
2 * Implementation of IShellBrowser for the File Open common dialog
3 *
5 */
7 #include <stdio.h>
8 #include "unknwn.h"
9 #include "filedlgbrowser.h"
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "winuser.h"
13 #include "wine/winestring.h"
14 #include "heap.h"
15 #include "shlguid.h"
16 #include "wine/obj_dataobject.h"
17 #include "debugtools.h"
18 #include "cdlg.h"
20 DEFAULT_DEBUG_CHANNEL(commdlg);
22 /**************************************************************************
23 * Structure
25 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
27 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
28 /* IUnknown */
29 IShellBrowserImpl_QueryInterface,
30 IShellBrowserImpl_AddRef,
31 IShellBrowserImpl_Release,
32 /* IOleWindow */
33 IShellBrowserImpl_GetWindow,
34 IShellBrowserImpl_ContextSensitiveHelp,
35 /* IShellBrowser */
36 IShellBrowserImpl_InsertMenusSB,
37 IShellBrowserImpl_SetMenuSB,
38 IShellBrowserImpl_RemoveMenusSB,
39 IShellBrowserImpl_SetStatusTextSB,
40 IShellBrowserImpl_EnableModelessSB,
41 IShellBrowserImpl_TranslateAcceleratorSB,
42 IShellBrowserImpl_BrowseObject,
43 IShellBrowserImpl_GetViewStateStream,
44 IShellBrowserImpl_GetControlWindow,
45 IShellBrowserImpl_SendControlMsg,
46 IShellBrowserImpl_QueryActiveShellView,
47 IShellBrowserImpl_OnViewWindowActive,
48 IShellBrowserImpl_SetToolbarItems
51 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
53 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
54 /* IUnknown */
55 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
56 IShellBrowserImpl_ICommDlgBrowser_AddRef,
57 IShellBrowserImpl_ICommDlgBrowser_Release,
58 /* ICommDlgBrowser */
59 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
60 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
61 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
65 /**************************************************************************
66 * Local Prototypes
69 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
70 #if 0
71 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
72 #endif
74 /**************************************************************************
75 * External Prototypes
77 extern const char *FileOpenDlgInfosStr;
79 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
80 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
81 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
82 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
83 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
85 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
86 LPITEMIDLIST pidlCurrentFolder,
87 LPSTR lpstrMask);
89 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
90 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
91 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
94 /**************************************************************************
95 * IShellBrowserImpl_Construct
97 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
99 IShellBrowserImpl *sb;
100 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
102 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
104 /* Initialisation of the member variables */
105 sb->ref=1;
106 sb->hwndOwner = hwndOwner;
108 /* Initialisation of the vTables */
109 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
110 sb->lpVtbl2 = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
112 COMDLG32_SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
113 &fodInfos->ShellInfos.pidlAbsCurrent);
115 TRACE("%p\n", sb);
117 return (IShellBrowser *) sb;
120 /**************************************************************************
123 * The INTERFACE of the IShellBrowser object
128 * IUnknown
131 /***************************************************************************
132 * IShellBrowserImpl_QueryInterface
134 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
135 REFIID riid,
136 LPVOID *ppvObj)
138 ICOM_THIS(IShellBrowserImpl, iface);
140 TRACE("(%p)\n", This);
142 *ppvObj = NULL;
144 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
145 { *ppvObj = This;
147 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
148 { *ppvObj = (IOleWindow*)This;
151 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
152 { *ppvObj = (IShellBrowser*)This;
155 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
156 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtbl2);
159 if(*ppvObj)
160 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
161 return S_OK;
163 return E_NOINTERFACE;
166 /**************************************************************************
167 * IShellBrowser::AddRef
169 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
171 ICOM_THIS(IShellBrowserImpl, iface);
173 TRACE("(%p)\n", This);
175 return ++(This->ref);
178 /**************************************************************************
179 * IShellBrowserImpl_Release
181 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
183 ICOM_THIS(IShellBrowserImpl, iface);
185 TRACE("(%p)\n", This);
187 if (!--(This->ref))
189 HeapFree(GetProcessHeap(),0, This);
190 return 0;
192 return This->ref;
196 * IOleWindow
199 /**************************************************************************
200 * IShellBrowserImpl_GetWindow (IOleWindow)
202 * Inherited from IOleWindow::GetWindow
204 * See Windows documentation for more details
206 * Note : We will never be window less in the File Open dialog
209 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
210 HWND * phwnd)
212 ICOM_THIS(IShellBrowserImpl, iface);
214 TRACE("(%p)\n", This);
216 if(!This->hwndOwner)
217 return E_FAIL;
219 *phwnd = This->hwndOwner;
221 return (*phwnd) ? S_OK : E_UNEXPECTED;
225 /**************************************************************************
226 * IShellBrowserImpl_ContextSensitiveHelp
228 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
229 BOOL fEnterMode)
231 ICOM_THIS(IShellBrowserImpl, iface);
233 TRACE("(%p)\n", This);
235 /* Feature not implemented */
236 return E_NOTIMPL;
240 * IShellBrowser
243 /**************************************************************************
244 * IShellBrowserImpl_BrowseObject
246 * See Windows documentation on IShellBrowser::BrowseObject for more details
248 * This function will override user specified flags and will always
249 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
251 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
252 LPCITEMIDLIST pidl,
253 UINT wFlags)
255 HRESULT hRes;
256 IShellFolder *psfTmp;
257 IShellView *psvTmp;
258 FileOpenDlgInfos *fodInfos;
259 LPITEMIDLIST pidlTmp;
260 HWND hwndView;
261 HWND hDlgWnd;
262 BOOL bViewHasFocus;
264 ICOM_THIS(IShellBrowserImpl, iface);
266 TRACE("(%p)(%p,0x%08x)\n", This, pidl, wFlags);
268 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
270 /* Format the pidl according to its parameter's category */
271 if(wFlags & SBSP_RELATIVE)
274 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
275 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
276 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
278 ERR("bind to object failed\n");
279 return hRes;
281 /* create an absolute pidl */
282 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
283 (LPITEMIDLIST)pidl);
285 else if(wFlags & SBSP_PARENT)
287 /* Browse the parent folder (ignores the pidl) */
288 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
289 psfTmp = GetShellFolderFromPidl(pidlTmp);
292 else /* SBSP_ABSOLUTE is 0x0000 */
294 /* An absolute pidl (relative from the desktop) */
295 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
296 psfTmp = GetShellFolderFromPidl(pidlTmp);
299 if(!psfTmp) return E_FAIL;
301 /* If the pidl to browse to is equal to the actual pidl ...
302 do nothing and pretend you did it*/
303 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
305 IShellFolder_Release(psfTmp);
306 COMDLG32_SHFree(pidlTmp);
307 return NOERROR;
310 /* Release the current DataObject */
311 if (fodInfos->Shell.FOIDataObject)
313 IDataObject_Release(fodInfos->Shell.FOIDataObject);
314 fodInfos->Shell.FOIDataObject = NULL;
317 /* Create the associated view */
318 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
319 &IID_IShellView, (LPVOID *)&psvTmp))) return hRes;
321 /* Check if listview has focus */
322 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
324 /* Get the foldersettings from the old view */
325 if(fodInfos->Shell.FOIShellView)
326 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
328 /* Release the old fodInfos->Shell.FOIShellView and update its value.
329 We have to update this early since ShellView_CreateViewWindow of native
330 shell32 calls OnStateChange and needs the correct view here.*/
331 if(fodInfos->Shell.FOIShellView)
333 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
334 IShellView_Release(fodInfos->Shell.FOIShellView);
336 fodInfos->Shell.FOIShellView = psvTmp;
338 /* Release old FOIShellFolder and update its value */
339 if (fodInfos->Shell.FOIShellFolder)
340 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
341 fodInfos->Shell.FOIShellFolder = psfTmp;
343 /* Release old pidlAbsCurrent and update its value */
344 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
345 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
347 /* Create the window */
348 TRACE("create view window\n");
349 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
350 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
351 &fodInfos->ShellInfos.rectView, &hwndView))) return hRes;
353 fodInfos->ShellInfos.hwndView = hwndView;
355 /* Select the new folder in the Look In combo box of the Open file dialog */
356 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
358 /* changes the tab order of the ListView to reflect the window's File Dialog */
359 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
360 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
362 /* Since we destroyed the old view if it had focus set focus to the newly created view */
363 if (bViewHasFocus)
364 SetFocus(fodInfos->ShellInfos.hwndView);
366 return hRes;
369 /**************************************************************************
370 * IShellBrowserImpl_EnableModelessSB
372 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
373 BOOL fEnable)
376 ICOM_THIS(IShellBrowserImpl, iface);
378 TRACE("(%p)\n", This);
380 /* Feature not implemented */
381 return E_NOTIMPL;
384 /**************************************************************************
385 * IShellBrowserImpl_GetControlWindow
387 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
388 UINT id,
389 HWND *lphwnd)
392 ICOM_THIS(IShellBrowserImpl, iface);
394 TRACE("(%p)\n", This);
396 /* Feature not implemented */
397 return E_NOTIMPL;
399 /**************************************************************************
400 * IShellBrowserImpl_GetViewStateStream
402 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
403 DWORD grfMode,
404 LPSTREAM *ppStrm)
407 ICOM_THIS(IShellBrowserImpl, iface);
409 TRACE("(%p)\n", This);
411 /* Feature not implemented */
412 return E_NOTIMPL;
414 /**************************************************************************
415 * IShellBrowserImpl_InsertMenusSB
417 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
418 HMENU hmenuShared,
419 LPOLEMENUGROUPWIDTHS lpMenuWidths)
422 ICOM_THIS(IShellBrowserImpl, iface);
424 TRACE("(%p)\n", This);
426 /* Feature not implemented */
427 return E_NOTIMPL;
429 /**************************************************************************
430 * IShellBrowserImpl_OnViewWindowActive
432 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
433 IShellView *ppshv)
436 ICOM_THIS(IShellBrowserImpl, iface);
438 TRACE("(%p)\n", This);
440 /* Feature not implemented */
441 return E_NOTIMPL;
443 /**************************************************************************
444 * IShellBrowserImpl_QueryActiveShellView
446 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
447 IShellView **ppshv)
450 ICOM_THIS(IShellBrowserImpl, iface);
452 FileOpenDlgInfos *fodInfos;
454 TRACE("(%p)\n", This);
456 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
458 if(!(*ppshv = fodInfos->Shell.FOIShellView))
460 return E_FAIL;
462 IShellView_AddRef(fodInfos->Shell.FOIShellView);
463 return NOERROR;
465 /**************************************************************************
466 * IShellBrowserImpl_RemoveMenusSB
468 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
469 HMENU hmenuShared)
472 ICOM_THIS(IShellBrowserImpl, iface);
474 TRACE("(%p)\n", This);
476 /* Feature not implemented */
477 return E_NOTIMPL;
479 /**************************************************************************
480 * IShellBrowserImpl_SendControlMsg
482 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
483 UINT id,
484 UINT uMsg,
485 WPARAM wParam,
486 LPARAM lParam,
487 LRESULT *pret)
490 ICOM_THIS(IShellBrowserImpl, iface);
491 LRESULT lres;
493 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
495 switch (id)
497 case FCW_TOOLBAR:
498 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
499 break;
500 default:
501 FIXME("ctrl id: %x\n", id);
502 return E_NOTIMPL;
504 if (pret) *pret = lres;
505 return S_OK;
507 /**************************************************************************
508 * IShellBrowserImpl_SetMenuSB
510 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
511 HMENU hmenuShared,
512 HOLEMENU holemenuReserved,
513 HWND hwndActiveObject)
516 ICOM_THIS(IShellBrowserImpl, iface);
518 TRACE("(%p)\n", This);
520 /* Feature not implemented */
521 return E_NOTIMPL;
523 /**************************************************************************
524 * IShellBrowserImpl_SetStatusTextSB
526 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
527 LPCOLESTR lpszStatusText)
530 ICOM_THIS(IShellBrowserImpl, iface);
532 TRACE("(%p)\n", This);
534 /* Feature not implemented */
535 return E_NOTIMPL;
537 /**************************************************************************
538 * IShellBrowserImpl_SetToolbarItems
540 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
541 LPTBBUTTON lpButtons,
542 UINT nButtons,
543 UINT uFlags)
546 ICOM_THIS(IShellBrowserImpl, iface);
548 TRACE("(%p)\n", This);
550 /* Feature not implemented */
551 return E_NOTIMPL;
553 /**************************************************************************
554 * IShellBrowserImpl_TranslateAcceleratorSB
556 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
557 LPMSG lpmsg,
558 WORD wID)
561 ICOM_THIS(IShellBrowserImpl, iface);
563 TRACE("(%p)\n", This);
565 /* Feature not implemented */
566 return E_NOTIMPL;
570 * ICommDlgBrowser
573 /***************************************************************************
574 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
576 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(ICommDlgBrowser *iface,
577 REFIID riid,
578 LPVOID *ppvObj)
580 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
582 TRACE("(%p)\n", This);
584 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
587 /**************************************************************************
588 * IShellBrowserImpl_ICommDlgBrowser_AddRef
590 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
592 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
594 TRACE("(%p)\n", This);
596 return IShellBrowserImpl_AddRef(This);
599 /**************************************************************************
600 * IShellBrowserImpl_ICommDlgBrowser_Release
602 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
604 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
606 TRACE("(%p)\n", This);
608 return IShellBrowserImpl_Release(This);
610 /**************************************************************************
611 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
613 * Called when a user double-clicks in the view or presses the ENTER key
615 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
616 IShellView *ppshv)
618 LPITEMIDLIST pidl;
619 FileOpenDlgInfos *fodInfos;
621 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
623 TRACE("(%p)\n", This);
625 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
627 /* If the selected object is not a folder, send a IDOK command to parent window */
628 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
630 HRESULT hRes;
632 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
633 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
634 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
636 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
638 else
640 /* Tell the dialog that the user selected a file */
641 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
644 /* Free memory used by pidl */
645 COMDLG32_SHFree((LPVOID)pidl);
647 return hRes;
650 return E_FAIL;
653 /**************************************************************************
654 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
656 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
657 IShellView *ppshv,
658 ULONG uChange)
661 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
663 TRACE("(%p shv=%p)\n", This, ppshv);
665 switch (uChange)
667 case CDBOSC_SETFOCUS:
668 /* FIXME: Reset the default button.
669 This should be taken care of by defdlg. If control
670 other than button receives focus the default button
671 should be restored. */
672 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
674 break;
675 case CDBOSC_KILLFOCUS:
677 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
678 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
679 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
681 break;
682 case CDBOSC_SELCHANGE:
683 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
684 case CDBOSC_RENAME:
685 /* nothing to do */
686 break;
689 return NOERROR;
692 /* copied from shell32 to avoid linking to it */
693 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
695 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
697 switch (src->uType)
699 case STRRET_WSTR:
700 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
701 COMDLG32_SHFree(src->u.pOleStr);
702 break;
704 case STRRET_CSTRA:
705 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
706 break;
708 case STRRET_OFFSETA:
709 if (pidl)
711 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
713 break;
715 default:
716 FIXME("unknown type!\n");
717 if (len)
718 { *(LPSTR)dest = '\0';
720 return(FALSE);
722 return S_OK;
724 /**************************************************************************
725 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
727 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
728 IShellView * ppshv,
729 LPCITEMIDLIST pidl)
731 FileOpenDlgInfos *fodInfos;
732 ULONG ulAttr;
733 STRRET str;
734 WCHAR szPathW[MAX_PATH];
736 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
738 TRACE("(%p)\n", This);
740 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
742 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
743 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
745 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
746 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
747 return S_FALSE;
749 /* always include directorys and links */
750 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
751 return S_OK;
753 /* Check if there is a mask to apply if not */
754 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
755 return S_OK;
757 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
759 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
761 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
762 return S_OK;
765 return S_FALSE;
769 /**************************************************************************
770 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
772 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
774 FileOpenDlgInfos *fodInfos;
776 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
778 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
779 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
781 /* release old selections */
782 if (fodInfos->Shell.FOIDataObject)
783 IDataObject_Release(fodInfos->Shell.FOIDataObject);
785 /* get a new DataObject from the ShellView */
786 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
787 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
788 return E_FAIL;
790 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
792 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
793 return S_OK;