[PATCH 04/10] comdlg32: Implement filetype filtering for the item dialog.

David Hedberg david.hedberg at gmail.com
Thu Mar 31 22:52:26 CDT 2011


---
 dlls/comdlg32/itemdlg.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
index 99e41a6..92ea665 100644
--- a/dlls/comdlg32/itemdlg.c
+++ b/dlls/comdlg32/itemdlg.c
@@ -1746,8 +1746,47 @@ static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
                                                        IShellView *shv, LPCITEMIDLIST pidl)
 {
     FileDialogImpl *This = impl_from_ICommDlgBrowser3(iface);
-    FIXME("Stub: %p (%p, %p)\n", This, shv, pidl);
-    return S_OK;
+    IShellItem *psi;
+    LPWSTR filename;
+    LPITEMIDLIST parent_pidl;
+    HRESULT hr;
+    ULONG attr;
+    TRACE("%p (%p, %p)\n", This, shv, pidl);
+
+    if(!This->filterspec_count)
+        return S_OK;
+
+    hr = SHGetIDListFromObject((IUnknown*)shv, &parent_pidl);
+    if(SUCCEEDED(hr))
+    {
+        LPITEMIDLIST full_pidl = ILCombine(parent_pidl, pidl);
+        hr = SHCreateItemFromIDList(full_pidl, &IID_IShellItem, (void**)&psi);
+        ILFree(parent_pidl);
+        ILFree(full_pidl);
+    }
+    if(FAILED(hr))
+    {
+        ERR("Failed to get shellitem (%08x).\n", hr);
+        return S_OK;
+    }
+
+    hr = IShellItem_GetAttributes(psi, SFGAO_FOLDER|SFGAO_LINK, &attr);
+    if(FAILED(hr) || (attr & (SFGAO_FOLDER | SFGAO_LINK)))
+    {
+        IShellItem_Release(psi);
+        return S_OK;
+    }
+
+    hr = S_OK;
+    if(SUCCEEDED(IShellItem_GetDisplayName(psi, SIGDN_PARENTRELATIVEPARSING, &filename)))
+    {
+        if(!PathMatchSpecW(filename, This->filterspecs[This->filetypeindex].pszSpec))
+            hr = S_FALSE;
+        CoTaskMemFree(filename);
+    }
+
+    IShellItem_Release(psi);
+    return hr;
 }
 
 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
-- 
1.7.4.1




More information about the wine-patches mailing list