[COMDLG32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / comdlg32 / filedlgbrowser.c
index 61416e4..a225e9e 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#define COBJMACROS
+#define NONAMELESSUNION
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winreg.h"
+
+#define NO_SHLWAPI_STREAM
+#include "shlwapi.h"
+#include "filedlgbrowser.h"
 #include "cdlg.h"
+#include "shlguid.h"
+#include "servprov.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
 typedef struct
 {
@@ -169,8 +191,8 @@ static BOOL COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITE
 */
 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
 {
+    FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndOwner);
     IShellBrowserImpl *sb;
-    FileOpenDlgInfos *fodInfos = GetPropA(hwndOwner,FileOpenDlgInfosStr);
 
     sb = COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
 
@@ -193,13 +215,11 @@ IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
 /***************************************************************************
 *  IShellBrowserImpl_QueryInterface
 */
-static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
-                                            REFIID riid,
-                                            LPVOID *ppvObj)
+static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface, REFIID riid, void **ppvObj)
 {
     IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
 
-    TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
+    TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
 
     *ppvObj = NULL;
 
@@ -219,7 +239,7 @@ static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
         return S_OK;
     }
 
-    FIXME("Unknown interface requested\n");
+    FIXME("unsupported interface, %s\n", debugstr_guid(riid));
     return E_NOINTERFACE;
 }
 
@@ -250,7 +270,6 @@ static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
     {
       COMDLG32_SHFree(This);
       TRACE("-- destroyed\n");
-      return 0;
     }
     return ref;
 }
@@ -330,7 +349,7 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
     COMDLG32_DumpSBSPFlags(wFlags);
 
-    fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+    fodInfos = get_filedlg_infoptr(This->hwndOwner);
 
     /* Format the pidl according to its parameter's category */
     if(wFlags & SBSP_RELATIVE)
@@ -539,7 +558,7 @@ static HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *ifac
 
     TRACE("(%p)\n", This);
 
-    fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+    fodInfos = get_filedlg_infoptr(This->hwndOwner);
 
     if(!(*ppshv = fodInfos->Shell.FOIShellView))
     {
@@ -743,7 +762,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDl
 
     TRACE("(%p)\n", This);
 
-    fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+    fodInfos = get_filedlg_infoptr(This->hwndOwner);
 
     /* If the selected object is not a folder, send an IDOK command to parent window */
     if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
@@ -781,7 +800,7 @@ static HRESULT IShellBrowserImpl_OnSelChange(IShellBrowserImpl *This, const IShe
 {
     FileOpenDlgInfos *fodInfos;
 
-    fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+    fodInfos = get_filedlg_infoptr(This->hwndOwner);
     TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
 
     /* release old selections */
@@ -824,7 +843,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBr
             break;
         case CDBOSC_KILLFOCUS:
            {
-                FileOpenDlgInfos *fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+                FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(This->hwndOwner);
                if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
                {
                    WCHAR szSave[16];
@@ -850,7 +869,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBr
 static LRESULT send_includeitem_notification(HWND hwndParentDlg, LPCITEMIDLIST pidl)
 {
     LRESULT hook_result = 0;
-    FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg, FileOpenDlgInfosStr);
+    FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndParentDlg);
 
     if(!fodInfos) return 0;
 
@@ -900,7 +919,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBr
 
     TRACE("(%p)\n", This);
 
-    fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
+    fodInfos = get_filedlg_infoptr(This->hwndOwner);
 
     ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
     IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
@@ -919,7 +938,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBr
         return S_OK;
 
     /* Check if there is a mask to apply if not */
-    if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
+    if(!fodInfos->ShellInfos.lpstrCurrentFilter || !fodInfos->ShellInfos.lpstrCurrentFilter[0])
         return S_OK;
 
     if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))