[COMDLG32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / comdlg32 / filedlgbrowser.c
index 776abfc..a225e9e 100644 (file)
@@ -25,7 +25,6 @@
 
 #define COBJMACROS
 #define NONAMELESSUNION
-#define NONAMELESSSTRUCT
 
 #include "windef.h"
 #include "winbase.h"
@@ -150,7 +149,7 @@ static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos)
 /* copied from shell32 to avoid linking to it */
 static BOOL COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
 {
-       TRACE("dest=%p len=0x%x strret=%p pidl=%p stub\n",dest,len,src,pidl);
+        TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest , len, src, pidl);
 
        switch (src->uType)
        {
@@ -192,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));
 
@@ -216,37 +215,31 @@ 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;
 
-    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
-    { *ppvObj = This;
-    }
-    else if(IsEqualIID(riid, &IID_IOleWindow))  /*IOleWindow*/
-    { *ppvObj = This;
-    }
-
-    else if(IsEqualIID(riid, &IID_IShellBrowser))  /*IShellBrowser*/
-    { *ppvObj = This;
-    }
-
-    else if(IsEqualIID(riid, &IID_ICommDlgBrowser))  /*ICommDlgBrowser*/
+    if(IsEqualIID(riid, &IID_IUnknown))
+        *ppvObj = &This->IShellBrowser_iface;
+    else if(IsEqualIID(riid, &IID_IOleWindow))
+        *ppvObj = &This->IShellBrowser_iface;
+    else if(IsEqualIID(riid, &IID_IShellBrowser))
+        *ppvObj = &This->IShellBrowser_iface;
+    else if(IsEqualIID(riid, &IID_ICommDlgBrowser))
         *ppvObj = &This->ICommDlgBrowser_iface;
-    else if(IsEqualIID(riid, &IID_IServiceProvider))  /* IServiceProvider */
+    else if(IsEqualIID(riid, &IID_IServiceProvider))
         *ppvObj = &This->IServiceProvider_iface;
 
-    if(*ppvObj)
-    { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
-      return S_OK;
+    if(*ppvObj) {
+        IUnknown_AddRef((IUnknown*)*ppvObj);
+        return S_OK;
     }
-    FIXME("Unknown interface requested\n");
+
+    FIXME("unsupported interface, %s\n", debugstr_guid(riid));
     return E_NOINTERFACE;
 }
 
@@ -277,7 +270,6 @@ static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
     {
       COMDLG32_SHFree(This);
       TRACE("-- destroyed\n");
-      return 0;
     }
     return ref;
 }
@@ -357,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)
@@ -456,6 +448,7 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
 
     /* Set view window control id to 5002 */
     SetWindowLongPtrW(hwndView, GWLP_ID, lst2);
+    SendMessageW( hwndView, WM_SETFONT, SendMessageW( GetParent(hwndView), WM_GETFONT, 0, 0 ), FALSE );
 
     /* Select the new folder in the Look In combo box of the Open file dialog */
     FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
@@ -565,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))
     {
@@ -769,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)))
@@ -807,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 */
@@ -850,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];
@@ -876,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;
 
@@ -926,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);
@@ -945,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)))