[COMDLG32] Sync with Wine Staging 3.9. CORE-14656
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 27 May 2018 03:06:36 +0000 (04:06 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 27 May 2018 03:06:36 +0000 (04:06 +0100)
13 files changed:
dll/win32/comdlg32/cdlg.h
dll/win32/comdlg32/cdlg32.c
dll/win32/comdlg32/colordlg.c
dll/win32/comdlg32/filedlg.c
dll/win32/comdlg32/filedlg31.c
dll/win32/comdlg32/filedlgbrowser.c
dll/win32/comdlg32/filedlgbrowser.h
dll/win32/comdlg32/finddlg.c
dll/win32/comdlg32/fontdlg.c
dll/win32/comdlg32/itemdlg.c
dll/win32/comdlg32/precomp.h
dll/win32/comdlg32/printdlg.c
media/doc/README.WINE

index 849b986..eebf1a9 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "dlgs.h"
 
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+
 /* Common dialogs implementation globals */
 #define COMDLG32_Atom   MAKEINTATOM(0xa000)     /* MS uses this one to identify props */
 
@@ -204,19 +206,7 @@ void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) DECLSPEC_HIDD
 extern BOOL GetFileName31A( OPENFILENAMEA *lpofn, UINT dlgType ) DECLSPEC_HIDDEN;
 extern BOOL GetFileName31W( OPENFILENAMEW *lpofn, UINT dlgType ) DECLSPEC_HIDDEN;
 
-/* ITEMIDLIST */
-
-extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST);
-extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
-extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILGetNext)(LPITEMIDLIST);
-extern BOOL (WINAPI *COMDLG32_PIDL_ILRemoveLastID)(LPCITEMIDLIST);
-extern BOOL (WINAPI *COMDLG32_PIDL_ILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
-extern UINT (WINAPI *COMDLG32_PIDL_ILGetSize)(LPCITEMIDLIST);
-
 /* SHELL */
-extern LPVOID (WINAPI *COMDLG32_SHAlloc)(DWORD);
-extern DWORD (WINAPI *COMDLG32_SHFree)(LPVOID);
-extern BOOL (WINAPI *COMDLG32_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR);
 extern LPITEMIDLIST (WINAPI *COMDLG32_SHSimpleIDListFromPathAW)(LPCVOID);
 
 #define ONOPEN_BROWSE 1
index daf03f0..1c21025 100644 (file)
@@ -32,6 +32,7 @@
 #include "commdlg.h"
 #include "cderr.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
@@ -43,20 +44,8 @@ DECLSPEC_HIDDEN HINSTANCE    COMDLG32_hInstance = 0;
 static DWORD COMDLG32_TlsIndex = TLS_OUT_OF_INDEXES;
 
 static HINSTANCE       SHELL32_hInstance;
-static HINSTANCE       SHFOLDER_hInstance;
-
-/* ITEMIDLIST */
-LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST) DECLSPEC_HIDDEN;
-LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILCombine)(LPCITEMIDLIST,LPCITEMIDLIST) DECLSPEC_HIDDEN;
-LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILGetNext)(LPITEMIDLIST) DECLSPEC_HIDDEN;
-BOOL (WINAPI *COMDLG32_PIDL_ILRemoveLastID)(LPCITEMIDLIST) DECLSPEC_HIDDEN;
-BOOL (WINAPI *COMDLG32_PIDL_ILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST) DECLSPEC_HIDDEN;
-UINT (WINAPI *COMDLG32_PIDL_ILGetSize)(LPCITEMIDLIST) DECLSPEC_HIDDEN;
 
 /* SHELL */
-LPVOID (WINAPI *COMDLG32_SHAlloc)(DWORD) DECLSPEC_HIDDEN;
-DWORD (WINAPI *COMDLG32_SHFree)(LPVOID) DECLSPEC_HIDDEN;
-BOOL (WINAPI *COMDLG32_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR) DECLSPEC_HIDDEN;
 LPITEMIDLIST (WINAPI *COMDLG32_SHSimpleIDListFromPathAW)(LPCVOID) DECLSPEC_HIDDEN;
 
 /***********************************************************************
@@ -88,33 +77,13 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
 
                SHELL32_hInstance = GetModuleHandleA("SHELL32.DLL");
 
-               /* ITEMIDLIST */
-               GPA(COMDLG32_PIDL_ILIsEqual, SHELL32_hInstance, (LPCSTR)21L);
-               GPA(COMDLG32_PIDL_ILCombine, SHELL32_hInstance, (LPCSTR)25L);
-               GPA(COMDLG32_PIDL_ILGetNext, SHELL32_hInstance, (LPCSTR)153L);
-               GPA(COMDLG32_PIDL_ILClone, SHELL32_hInstance, (LPCSTR)18L);
-               GPA(COMDLG32_PIDL_ILRemoveLastID, SHELL32_hInstance, (LPCSTR)17L);
-               GPA(COMDLG32_PIDL_ILGetSize, SHELL32_hInstance, (LPCSTR)152L);
-
                /* SHELL */
                GPA(COMDLG32_SHSimpleIDListFromPathAW, SHELL32_hInstance, (LPCSTR)162);
-               GPA(COMDLG32_SHAlloc, SHELL32_hInstance, (LPCSTR)196L);
-               GPA(COMDLG32_SHFree, SHELL32_hInstance, (LPCSTR)195L);
-
-               /* for the first versions of shell32 SHGetFolderPathW is in SHFOLDER.DLL */
-               COMDLG32_SHGetFolderPathW = (void*)GetProcAddress(SHELL32_hInstance,"SHGetFolderPathW");
-               if (!COMDLG32_SHGetFolderPathW)
-               {
-                 SHFOLDER_hInstance = LoadLibraryA("SHFOLDER.DLL");
-                 GPA(COMDLG32_SHGetFolderPathW, SHFOLDER_hInstance,"SHGetFolderPathW");
-               }
-
                break;
 
        case DLL_PROCESS_DETACH:
             if (Reserved) break;
             if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES) TlsFree(COMDLG32_TlsIndex);
-            if(SHFOLDER_hInstance) FreeLibrary(SHFOLDER_hInstance);
             break;
        }
        return TRUE;
@@ -128,16 +97,17 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
  *             Success: Pointer to a heap block
  *             Failure: null
  */
-LPVOID COMDLG32_AllocMem(
-       int size        /* [in] Block size to allocate */
-) {
-        LPVOID ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
-        if(!ptr)
-        {
-               COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
-                return NULL;
-        }
-        return ptr;
+void *COMDLG32_AllocMem(int size)
+{
+    void *ptr = heap_alloc_zero(size);
+
+    if (!ptr)
+    {
+        COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
+        return NULL;
+    }
+
+    return ptr;
 }
 
 
index bead9ba..1e8c26b 100644 (file)
 #include "winuser.h"
 #include "commdlg.h"
 #include "dlgs.h"
-#include "wine/debug.h"
 #include "cderr.h"
 #include "cdlg.h"
 
+#include "wine/debug.h"
+#include "wine/heap.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
 static INT_PTR CALLBACK ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
@@ -400,7 +402,7 @@ static int CC_CheckDigitsInEdit( HWND hwnd, int maxval )
  long editpos;
  char buffer[30];
 
- GetWindowTextA(hwnd, buffer, sizeof(buffer));
+ GetWindowTextA(hwnd, buffer, ARRAY_SIZE(buffer));
  m = strlen(buffer);
  result = 0;
 
@@ -858,7 +860,7 @@ static LRESULT CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
        return FALSE;
    }
 
-   lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
+   lpp = heap_alloc_zero(sizeof(*lpp));
    lpp->lpcc = cc;
    lpp->hwndSelf = hDlg;
 
@@ -1215,7 +1217,7 @@ static INT_PTR CALLBACK ColorDlgProc( HWND hDlg, UINT message,
          case WM_NCDESTROY:
                        DeleteDC(lpp->hdcMem);
                        DeleteObject(lpp->hbmMem);
-                        HeapFree(GetProcessHeap(), 0, lpp);
+                        heap_free(lpp);
                         RemovePropW( hDlg, szColourDialogProp );
                        break;
          case WM_COMMAND:
@@ -1326,7 +1328,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
   LPWSTR template_name = NULL;
   BOOL ret;
 
-  LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW));
+  CHOOSECOLORW *lpcc = heap_alloc_zero(sizeof(*lpcc));
   lpcc->lStructSize = sizeof(*lpcc);
   lpcc->hwndOwner = lpChCol->hwndOwner;
   lpcc->hInstance = lpChCol->hInstance;
@@ -1338,7 +1340,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
   if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
       if (!IS_INTRESOURCE(lpChCol->lpTemplateName)) {
          INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0);
-          template_name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+          template_name = heap_alloc( len * sizeof(WCHAR) );
           MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, template_name, len );
           lpcc->lpTemplateName = template_name;
       } else {
@@ -1350,7 +1352,8 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
 
   if (ret)
       lpChCol->rgbResult = lpcc->rgbResult;
-  HeapFree(GetProcessHeap(), 0, template_name);
-  HeapFree(GetProcessHeap(), 0, lpcc);
+
+  heap_free(template_name);
+  heap_free(lpcc);
   return ret;
 }
index 41b7966..cd85647 100644 (file)
@@ -80,6 +80,7 @@
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
@@ -88,8 +89,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
 OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
 
-#define IsHooked(fodInfos) \
-       ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
 /***********************************************************************
  * Data structure and global variables
  */
@@ -127,46 +126,21 @@ typedef struct tagLookInInfo
 /* Undefined windows message sent by CreateViewObject*/
 #define WM_GETISHELLBROWSER  WM_USER+7
 
+#define TBPLACES_CMDID_PLACE0    0xa064
+#define TBPLACES_CMDID_PLACE1    0xa065
+#define TBPLACES_CMDID_PLACE2    0xa066
+#define TBPLACES_CMDID_PLACE3    0xa067
+#define TBPLACES_CMDID_PLACE4    0xa068
+
 /* NOTE
  * Those macros exist in windowsx.h. However, you can't really use them since
  * they rely on the UNICODE defines and can't be used inside Wine itself.
  */
 
 /* Combo box macros */
-#define CBAddString(hwnd,str) \
-    SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)(str));
-
-#define CBInsertString(hwnd,str,pos) \
-    SendMessageW(hwnd, CB_INSERTSTRING, (WPARAM)(pos), (LPARAM)(str));
-
-#define CBDeleteString(hwnd,pos) \
-    SendMessageW(hwnd, CB_DELETESTRING, (WPARAM)(pos), 0);
-
-#define CBSetItemDataPtr(hwnd,iItemId,dataPtr) \
-    SendMessageW(hwnd, CB_SETITEMDATA, (WPARAM)(iItemId), (LPARAM)(dataPtr));
-
 #define CBGetItemDataPtr(hwnd,iItemId) \
     SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)
 
-#define CBGetLBText(hwnd,iItemId,str) \
-    SendMessageW(hwnd, CB_GETLBTEXT, (WPARAM)(iItemId), (LPARAM)(str));
-
-#define CBGetCurSel(hwnd) \
-    SendMessageW(hwnd, CB_GETCURSEL, 0, 0);
-
-#define CBSetCurSel(hwnd,pos) \
-    SendMessageW(hwnd, CB_SETCURSEL, (WPARAM)(pos), 0);
-
-#define CBGetCount(hwnd) \
-    SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
-#define CBShowDropDown(hwnd,show) \
-    SendMessageW(hwnd, CB_SHOWDROPDOWN, (WPARAM)(show), 0);
-#define CBSetItemHeight(hwnd,index,height) \
-    SendMessageW(hwnd, CB_SETITEMHEIGHT, (WPARAM)(index), (LPARAM)(height));
-
-#define CBSetExtendedUI(hwnd,flag) \
-    SendMessageW(hwnd, CB_SETEXTENDEDUI, (WPARAM)(flag), 0)
-
 static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
 static SIZE MemDialogSize = { 0, 0}; /* keep size of the (resizable) dialog */
 
@@ -184,6 +158,16 @@ FileOpenDlgInfos *get_filedlg_infoptr(HWND hwnd)
     return GetPropW(hwnd, filedlg_info_propnameW);
 }
 
+static BOOL is_dialog_hooked(const FileOpenDlgInfos *info)
+{
+    return (info->ofnInfos->Flags & OFN_ENABLEHOOK) && info->ofnInfos->lpfnHook;
+}
+
+static BOOL filedialog_is_readonly_hidden(const FileOpenDlgInfos *info)
+{
+    return (info->ofnInfos->Flags & OFN_HIDEREADONLY) || (info->DlgInfos.dwDlgProp & FODPROP_SAVEDLG);
+}
+
 /***********************************************************************
  * Prototypes
  */
@@ -202,7 +186,6 @@ static LRESULT FILEDLG95_SHELL_Init(HWND hwnd);
 static BOOL    FILEDLG95_SHELL_UpFolder(HWND hwnd);
 static BOOL    FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
 static void    FILEDLG95_SHELL_Clean(HWND hwnd);
-static BOOL    FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);
 
 /* Functions used by the EDIT box */
 static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed);
@@ -238,15 +221,131 @@ static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
 static UINT GetNumSelected( IDataObject *doSelected );
 static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
 
-/* Shell memory allocation */
-static void *MemAlloc(UINT size);
-static void MemFree(void *mem);
-
 static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
 static BOOL BrowseSelectedFolder(HWND hwnd);
 
+static BOOL get_config_key_as_dword(HKEY hkey, const WCHAR *name, DWORD *value)
+{
+    DWORD type, data, size;
+
+    size = sizeof(data);
+    if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size))
+    {
+        *value = data;
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static BOOL get_config_key_dword(HKEY hkey, const WCHAR *name, DWORD *value)
+{
+    DWORD type, data, size;
+
+    size = sizeof(data);
+    if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size) && type == REG_DWORD)
+    {
+        *value = data;
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static BOOL get_config_key_string(HKEY hkey, const WCHAR *name, WCHAR **value)
+{
+    DWORD type, size;
+    WCHAR *str;
+
+    if (hkey && !RegQueryValueExW(hkey, name, 0, &type, NULL, &size))
+    {
+        if (type != REG_SZ && type != REG_EXPAND_SZ)
+            return FALSE;
+    }
+
+    str = heap_alloc(size);
+    if (RegQueryValueExW(hkey, name, 0, &type, (BYTE *)str, &size))
+    {
+        heap_free(str);
+        return FALSE;
+    }
+
+    *value = str;
+    return TRUE;
+}
+
+static BOOL is_places_bar_enabled(const FileOpenDlgInfos *fodInfos)
+{
+    static const WCHAR noplacesbarW[] = {'N','o','P','l','a','c','e','s','B','a','r',0};
+    DWORD value;
+    HKEY hkey;
+
+    if (fodInfos->ofnInfos->lStructSize != sizeof(*fodInfos->ofnInfos) ||
+            (fodInfos->ofnInfos->FlagsEx & OFN_EX_NOPLACESBAR) ||
+           !(fodInfos->ofnInfos->Flags & OFN_EXPLORER))
+    {
+        return FALSE;
+    }
+
+    if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32", &hkey))
+        return TRUE;
+
+    value = 0;
+    get_config_key_as_dword(hkey, noplacesbarW, &value);
+    RegCloseKey(hkey);
+    return value == 0;
+}
+
+static void filedlg_collect_places_pidls(FileOpenDlgInfos *fodInfos)
+{
+    static const int default_places[] =
+    {
+        CSIDL_DESKTOP,
+        CSIDL_MYDOCUMENTS,
+        CSIDL_DRIVES,
+    };
+    unsigned int i;
+    HKEY hkey;
+
+    if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32\\Placesbar",
+            &hkey))
+    {
+        for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
+        {
+            static const WCHAR placeW[] = {'P','l','a','c','e','%','d',0};
+            WCHAR nameW[8];
+            DWORD value;
+            HRESULT hr;
+            WCHAR *str;
+
+            sprintfW(nameW, placeW, i);
+            if (get_config_key_dword(hkey, nameW, &value))
+            {
+                hr = SHGetSpecialFolderLocation(NULL, value, &fodInfos->places[i]);
+                if (FAILED(hr))
+                    WARN("Unrecognized special folder %u.\n", value);
+            }
+            else if (get_config_key_string(hkey, nameW, &str))
+            {
+                hr = SHParseDisplayName(str, NULL, &fodInfos->places[i], 0, NULL);
+                if (FAILED(hr))
+                    WARN("Failed to parse custom places location, %s.\n", debugstr_w(str));
+                heap_free(str);
+            }
+        }
+
+        /* FIXME: eliminate duplicates. */
+
+        RegCloseKey(hkey);
+        return;
+    }
+
+    for (i = 0; i < ARRAY_SIZE(default_places); i++)
+        SHGetSpecialFolderLocation(NULL, default_places[i], &fodInfos->places[i]);
+}
+
 /***********************************************************************
  *      GetFileName95
  *
@@ -263,6 +362,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
     void *template;
     HRSRC hRes;
     HANDLE hDlgTmpl = 0;
+    WORD templateid;
 
     /* test for missing functionality */
     if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
@@ -273,7 +373,12 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
 
     /* Create the dialog from a template */
 
-    if(!(hRes = FindResourceW(COMDLG32_hInstance,MAKEINTRESOURCEW(NEWFILEOPENORD),(LPCWSTR)RT_DIALOG)))
+    if (is_places_bar_enabled(fodInfos))
+        templateid = NEWFILEOPENV2ORD;
+    else
+        templateid = NEWFILEOPENORD;
+
+    if (!(hRes = FindResourceW(COMDLG32_hInstance, MAKEINTRESOURCEW(templateid), (LPCWSTR)RT_DIALOG)))
     {
         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
         return FALSE;
@@ -299,7 +404,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
     }
 
     /* old style hook messages */
-    if (IsHooked(fodInfos))
+    if (is_dialog_hooked(fodInfos))
     {
       fodInfos->HookMsg.fileokstring = RegisterWindowMessageW(FILEOKSTRINGW);
       fodInfos->HookMsg.lbselchstring = RegisterWindowMessageW(LBSELCHSTRINGW);
@@ -338,7 +443,7 @@ static WCHAR *heap_strdupAtoW(const char *str)
         return NULL;
 
     len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
-    ret = MemAlloc(len * sizeof(WCHAR));
+    ret = heap_alloc(len * sizeof(WCHAR));
     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
 
     return ret;
@@ -368,7 +473,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
 
     if (ofn->lpstrFile)
     {
-        info->filename = MemAlloc(ofn->nMaxFile * sizeof(WCHAR));
+        info->filename = heap_alloc(ofn->nMaxFile * sizeof(WCHAR));
         lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
     }
 
@@ -377,7 +482,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
         DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
         if (len)
         {
-            info->initdir = MemAlloc(len * sizeof(WCHAR));
+            info->initdir = heap_alloc(len * sizeof(WCHAR));
             ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len);
         }
     }
@@ -399,7 +504,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
     if (ofn->lpstrFile)
     {
         len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
-        ofnW.lpstrFile = MemAlloc(len * sizeof(WCHAR));
+        ofnW.lpstrFile = heap_alloc(len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
         ofnW.nMaxFile = len;
     }
@@ -415,7 +520,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
         s++;
         n = s - ofn->lpstrFilter;
         len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0);
-        ofnW.lpstrFilter = MemAlloc(len * sizeof(WCHAR));
+        ofnW.lpstrFilter = heap_alloc(len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len);
     }
 
@@ -431,7 +536,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
         if (*s) s = s+strlen(s)+1;
         n = s - ofn->lpstrCustomFilter;
         len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0);
-        ofnW.lpstrCustomFilter = MemAlloc(len * sizeof(WCHAR));
+        ofnW.lpstrCustomFilter = heap_alloc(len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len);
     }
 
@@ -442,8 +547,8 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
     info->unicode = FALSE;
 
     /* free what was duplicated */
-    MemFree((WCHAR *)ofnW.lpstrInitialDir);
-    MemFree((WCHAR *)ofnW.lpstrFile);
+    heap_free((void *)ofnW.lpstrInitialDir);
+    heap_free(ofnW.lpstrFile);
 }
 
 /***********************************************************************
@@ -454,12 +559,13 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
 static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
 {
     WCHAR *current_dir = NULL;
+    unsigned int i;
     BOOL ret;
 
     /* save current directory */
     if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
     {
-        current_dir = MemAlloc(MAX_PATH * sizeof(WCHAR));
+        current_dir = heap_alloc(MAX_PATH * sizeof(WCHAR));
         GetCurrentDirectoryW(MAX_PATH, current_dir);
     }
 
@@ -496,19 +602,23 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
     if (current_dir)
     {
         SetCurrentDirectoryW(current_dir);
-        MemFree(current_dir);
+        heap_free(current_dir);
     }
 
     if (!info->unicode)
     {
-        MemFree((WCHAR *)info->defext);
-        MemFree((WCHAR *)info->title);
-        MemFree((WCHAR *)info->filter);
-        MemFree((WCHAR *)info->customfilter);
+        heap_free((void *)info->defext);
+        heap_free((void *)info->title);
+        heap_free((void *)info->filter);
+        heap_free((void *)info->customfilter);
     }
 
-    MemFree(info->filename);
-    MemFree(info->initdir);
+    heap_free(info->filename);
+    heap_free(info->initdir);
+
+    for (i = 0; i < ARRAY_SIZE(info->places); i++)
+        ILFree(info->places[i]);
+
     return ret;
 }
 
@@ -586,7 +696,7 @@ int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileLis
 
        /* we might get single filename without any '"',
         * so we need nStrLen + terminating \0 + end-of-list \0 */
-       *lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) );
+       *lpstrFileList = heap_alloc((nStrLen + 2) * sizeof(WCHAR));
        *sizeUsed = 0;
 
        /* build delimited file list from filenames */
@@ -833,15 +943,15 @@ static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
       }
       if (fodInfos->unicode)
           hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd,
-              IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
+              is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
               (LPARAM)fodInfos->ofnInfos);
       else
           hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
-              IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
+              is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
               (LPARAM)fodInfos->ofnInfos);
       return hChildDlg;
     }
-    else if( IsHooked(fodInfos))
+    else if (is_dialog_hooked(fodInfos))
     {
       RECT rectHwnd;
       struct  {
@@ -914,7 +1024,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result
 
     /* get path and filenames */
     len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
-    buffer = HeapAlloc( GetProcessHeap(), 0, (len + 2 + MAX_PATH) * sizeof(WCHAR) );
+    buffer = heap_alloc( (len + 2 + MAX_PATH) * sizeof(WCHAR) );
     COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
     if (len)
     {
@@ -934,7 +1044,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result
         if (total <= size) WideCharToMultiByte( CP_ACP, 0, buffer, -1, result, size, NULL, NULL );
         TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result));
     }
-    HeapFree( GetProcessHeap(), 0, buffer );
+    heap_free( buffer );
     return total;
 }
 
@@ -972,7 +1082,7 @@ static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM
             break;
 
         case CDM_GETFOLDERIDLIST:
-            retval = COMDLG32_PIDL_ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
+            retval = ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
             if (retval <= wParam)
                 memcpy((void*)lParam, fodInfos->ShellInfos.pidlAbsCurrent, retval);
             break;
@@ -1328,11 +1438,25 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
     case WM_DESTROY:
       {
           FileOpenDlgInfos * fodInfos = get_filedlg_infoptr(hwnd);
+          HWND places_bar = GetDlgItem(hwnd, IDC_TOOLBARPLACES);
+          HIMAGELIST himl;
+
           if (fodInfos && fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
               MemDialogSize = fodInfos->sizedlg;
-          RemovePropW(hwnd, filedlg_info_propnameW);
+
+          if (places_bar)
+          {
+              himl = (HIMAGELIST)SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_GETIMAGELIST, 0, 0);
+              SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETIMAGELIST, 0, 0);
+              ImageList_Destroy(himl);
+          }
           return FALSE;
       }
+
+    case WM_NCDESTROY:
+        RemovePropW(hwnd, filedlg_info_propnameW);
+        return 0;
+
     case WM_NOTIFY:
     {
        LPNMHDR lpnmh = (LPNMHDR)lParam;
@@ -1417,8 +1541,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
   RECT rectlook;
 
   HIMAGELIST toolbarImageList;
-  SHFILEINFOA shFileInfo;
   ITEMIDLIST *desktopPidl;
+  SHFILEINFOW fileinfo;
 
   FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
 
@@ -1466,13 +1590,13 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
 
   if (fodInfos->unicode)
       fodInfos->DlgInfos.hwndTB = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
-          WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
+          WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER | CCS_NORESIZE,
           rectTB.left, rectTB.top,
           rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
           hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
   else
       fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL,
-          WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
+          WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER | CCS_NORESIZE,
           rectTB.left, rectTB.top,
           rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
           hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
@@ -1487,17 +1611,57 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
   /* Retrieve and add desktop icon to the toolbar */
   toolbarImageList = (HIMAGELIST)SendMessageW(fodInfos->DlgInfos.hwndTB, TB_GETIMAGELIST, 0, 0L);
   SHGetSpecialFolderLocation(hwnd, CSIDL_DESKTOP, &desktopPidl);
-  SHGetFileInfoA((LPCSTR)desktopPidl, 0, &shFileInfo, sizeof(shFileInfo),
+  SHGetFileInfoW((const WCHAR *)desktopPidl, 0, &fileinfo, sizeof(fileinfo),
     SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON);
-  ImageList_AddIcon(toolbarImageList, shFileInfo.hIcon);
+  ImageList_AddIcon(toolbarImageList, fileinfo.hIcon);
 
-  DestroyIcon(shFileInfo.hIcon);
+  DestroyIcon(fileinfo.hIcon);
   CoTaskMemFree(desktopPidl);
 
   /* Finish Toolbar Construction */
   SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSW, 9, (LPARAM) tbb);
   SendMessageW(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
 
+  if (is_places_bar_enabled(fodInfos))
+  {
+      TBBUTTON tb = { 0 };
+      HIMAGELIST himl;
+      RECT rect;
+      int i, cx;
+
+      SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_BUTTONSTRUCTSIZE, 0, 0);
+      GetClientRect(GetDlgItem(hwnd, IDC_TOOLBARPLACES), &rect);
+      cx = rect.right - rect.left;
+
+      SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cx, cx));
+      himl = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), ILC_COLOR32, 4, 1);
+
+      filedlg_collect_places_pidls(fodInfos);
+      for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
+      {
+          int index;
+
+          if (!fodInfos->places[i])
+              continue;
+
+          memset(&fileinfo, 0, sizeof(fileinfo));
+          SHGetFileInfoW((const WCHAR *)fodInfos->places[i], 0, &fileinfo, sizeof(fileinfo),
+              SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_ICON);
+          index = ImageList_AddIcon(himl, fileinfo.hIcon);
+
+          tb.iBitmap = index;
+          tb.iString = (INT_PTR)fileinfo.szDisplayName;
+          tb.fsState = TBSTATE_ENABLED | TBSTATE_WRAP;
+          tb.idCommand = TBPLACES_CMDID_PLACE0 + i;
+          SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_ADDBUTTONSW, 1, (LPARAM)&tb);
+
+          DestroyIcon(fileinfo.hIcon);
+      }
+
+      SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETIMAGELIST, 0, (LPARAM)himl);
+      SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cx * 3 / 4));
+  }
+
   /* Set the window text with the text specified in the OPENFILENAME structure */
   if(fodInfos->title)
   {
@@ -1506,7 +1670,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
   else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
   {
       WCHAR buf[64];
-      LoadStringW(COMDLG32_hInstance, IDS_SAVE_AS, buf, sizeof(buf)/sizeof(WCHAR));
+      LoadStringW(COMDLG32_hInstance, IDS_SAVE_AS, buf, ARRAY_SIZE(buf));
       SetWindowTextW(hwnd, buf);
   }
 
@@ -1536,8 +1700,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
             else
                 *fodInfos->filename = '\0';
 
-            MemFree(fodInfos->initdir);
-            fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
+            heap_free(fodInfos->initdir);
+            fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
             lstrcpyW(fodInfos->initdir, tmpBuf);
             handledPath = TRUE;
             TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
@@ -1571,8 +1735,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
             result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
             if (result) {
                 *nameBit = 0x00;
-                MemFree(fodInfos->initdir);
-                fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
+                heap_free(fodInfos->initdir);
+                fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
                 lstrcpyW(fodInfos->initdir, tmpBuf2);
                 handledPath = TRUE;
                 TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
@@ -1580,7 +1744,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
         }
         else if (fodInfos->initdir)
         {
-            MemFree(fodInfos->initdir);
+            heap_free(fodInfos->initdir);
             fodInfos->initdir = NULL;
             TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
         }
@@ -1606,8 +1770,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
             *nameBit = 0x00;
 
             len = lstrlenW(tmpBuf);
-            MemFree(fodInfos->initdir);
-            fodInfos->initdir = MemAlloc((len+1)*sizeof(WCHAR));
+            heap_free(fodInfos->initdir);
+            fodInfos->initdir = heap_alloc((len+1)*sizeof(WCHAR));
             lstrcpyW(fodInfos->initdir, tmpBuf);
 
             handledPath = TRUE;
@@ -1619,7 +1783,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
 
       /* 4. Win2000+: Recently used */
       if (!handledPath && win2000plus) {
-          fodInfos->initdir = MemAlloc(MAX_PATH * sizeof(WCHAR));
+          fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
           fodInfos->initdir[0] = '\0';
 
           FILEDLG95_MRU_load_filename(fodInfos->initdir);
@@ -1627,7 +1791,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
           if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){
              handledPath = TRUE;
           }else{
-             MemFree(fodInfos->initdir);
+             heap_free(fodInfos->initdir);
              fodInfos->initdir = NULL;
           }
       }
@@ -1659,8 +1823,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
 
            } else {
 
-               MemFree(fodInfos->initdir);
-               fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+               heap_free(fodInfos->initdir);
+               fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
                GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
 
                handledPath = TRUE;
@@ -1674,24 +1838,25 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
 
       /* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
       if (!handledPath && (win2000plus || win98plus)) {
-          fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+          fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
 
-          if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir))
+          if (SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir) == S_OK)
           {
-            if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir))
-            {
-                /* last fallback */
-                GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
-                TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
-            } else {
+              if (SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir) == S_OK)
+              {
+                  /* last fallback */
+                  GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
+                  TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
+              }
+              else
                 TRACE("No personal dir, using desktop instead: %s\n", debugstr_w(fodInfos->initdir));
-            }
-          } else {
-            TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
           }
+          else
+              TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
+
           handledPath = TRUE;
       } else if (!handledPath) {
-          fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+          fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
           GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
           handledPath = TRUE;
           TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
@@ -1707,7 +1872,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
   }
 
   /* Must the open as read only check box be hidden? */
-  if(fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY)
+  if (filedialog_is_readonly_hidden(fodInfos))
   {
     ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
     EnableWindow(GetDlgItem(hwnd, IDC_OPENREADONLY), FALSE);
@@ -1724,9 +1889,9 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
   if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
   {
       WCHAR buf[16];
-      LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, buf, sizeof(buf)/sizeof(WCHAR));
+      LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, buf, ARRAY_SIZE(buf));
       SetDlgItemTextW(hwnd, IDOK, buf);
-      LoadStringW(COMDLG32_hInstance, IDS_SAVE_IN, buf, sizeof(buf)/sizeof(WCHAR));
+      LoadStringW(COMDLG32_hInstance, IDS_SAVE_IN, buf, ARRAY_SIZE(buf));
       SetDlgItemTextW(hwnd, IDC_LOOKINSTATIC, buf);
   }
 
@@ -1751,7 +1916,7 @@ static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
     UINT flags = SWP_NOACTIVATE;
 
     ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
-        (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
+        filedialog_is_readonly_hidden(fodInfos) && !(fodInfos->ofnInfos->Flags & OFN_SHOWHELP));
 
     /* resize the custom dialog to the parent size */
     if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
@@ -1772,7 +1937,7 @@ static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
     /* Resize the height; if opened as read-only, checkbox and help button are
      * hidden and we are not using a custom template nor a customDialog
      */
-    if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
+    if (filedialog_is_readonly_hidden(fodInfos) &&
                 (!(fodInfos->ofnInfos->Flags &
                    (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
     {
@@ -1824,8 +1989,7 @@ static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
   /* Browse to the initial directory */
   IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
 
-  /* Free pidlItem memory */
-  COMDLG32_SHFree(pidlItemId);
+  ILFree(pidlItemId);
 
   return TRUE;
 }
@@ -1840,6 +2004,20 @@ void FILEDLG95_Clean(HWND hwnd)
       FILEDLG95_LOOKIN_Clean(hwnd);
       FILEDLG95_SHELL_Clean(hwnd);
 }
+
+
+/***********************************************************************
+ * Browse to arbitrary pidl
+ */
+static void filedlg_browse_to_pidl(const FileOpenDlgInfos *info, LPITEMIDLIST pidl)
+{
+    TRACE("%p, %p\n", info->ShellInfos.hwndOwner, pidl);
+
+    IShellBrowser_BrowseObject(info->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
+    if (info->ofnInfos->Flags & OFN_EXPLORER)
+        SendCustomDlgNotificationMessage(info->ShellInfos.hwndOwner, CDN_FOLDERCHANGE);
+}
+
 /***********************************************************************
  *      FILEDLG95_OnWMCommand
  *
@@ -1849,9 +2027,9 @@ static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
 {
   FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
   WORD wNotifyCode = HIWORD(wParam); /* notification code */
-  WORD wID = LOWORD(wParam);         /* item, control, or accelerator identifier */
+  WORD id = LOWORD(wParam);         /* item, control, or accelerator identifier */
 
-  switch(wID)
+  switch (id)
   {
     /* OK button */
   case IDOK:
@@ -1888,9 +2066,24 @@ static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
   case FCIDM_TB_REPORTVIEW:
     FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILSA);
     break;
-    /* Details option button */
+
   case FCIDM_TB_DESKTOP:
-    FILEDLG95_SHELL_BrowseToDesktop(hwnd);
+  {
+    LPITEMIDLIST pidl;
+
+    SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidl);
+    filedlg_browse_to_pidl(fodInfos, pidl);
+    ILFree(pidl);
+    break;
+  }
+
+  /* Places bar */
+  case TBPLACES_CMDID_PLACE0:
+  case TBPLACES_CMDID_PLACE1:
+  case TBPLACES_CMDID_PLACE2:
+  case TBPLACES_CMDID_PLACE3:
+  case TBPLACES_CMDID_PLACE4:
+    filedlg_browse_to_pidl(fodInfos, fodInfos->places[id - TBPLACES_CMDID_PLACE0]);
     break;
 
   case edt1:
@@ -1932,7 +2125,7 @@ static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
 static BOOL FILEDLG95_SendFileOK( HWND hwnd, FileOpenDlgInfos *fodInfos )
 {
     /* ask the hook if we can close */
-    if(IsHooked(fodInfos))
+    if (is_dialog_hooked(fodInfos))
     {
         LRESULT retval = 0;
 
@@ -2020,7 +2213,7 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
 
       /* move to the next file in the list of files */
       lpstrTemp += lstrlenW(lpstrTemp) + 1;
-      COMDLG32_SHFree(pidl);
+      ILFree(pidl);
     }
   }
 
@@ -2158,7 +2351,8 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
     HKEY hkey;
 
     /* get the current executable's name */
-    if(!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, sizeof(module_path)/sizeof(module_path[0]))) {
+    if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
+    {
         WARN("GotModuleFileName failed: %d\n", GetLastError());
         return;
     }
@@ -2183,7 +2377,7 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
 
         final_len = path_len + lstrlenW(module_name) + 2;
 
-        final = MemAlloc(final_len * sizeof(WCHAR));
+        final = heap_alloc(final_len * sizeof(WCHAR));
         if(!final)
             return;
         lstrcpyW(final, module_name);
@@ -2194,12 +2388,12 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
                 final_len * sizeof(WCHAR));
         if(ret){
             WARN("Error saving MRU data to slot %s: %d\n", wine_dbgstr_w(slot_name), ret);
-            MemFree(final);
+            heap_free(final);
             RegCloseKey(hkey);
             return;
         }
 
-        MemFree(final);
+        heap_free(final);
     }
 
     { /* update MRUList value */
@@ -2245,7 +2439,8 @@ static void FILEDLG95_MRU_load_filename(LPWSTR stored_path)
     WCHAR module_path[MAX_PATH], *module_name;
 
     /* get the current executable's name */
-    if(!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, sizeof(module_path)/sizeof(module_path[0]))) {
+    if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
+    {
         WARN("GotModuleFileName failed: %d\n", GetLastError());
         return;
     }
@@ -2264,10 +2459,10 @@ void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
   WCHAR strMsgTitle[MAX_PATH];
   WCHAR strMsgText [MAX_PATH];
   if (idCaption)
-    LoadStringW(COMDLG32_hInstance, idCaption, strMsgTitle, sizeof(strMsgTitle)/sizeof(WCHAR));
+    LoadStringW(COMDLG32_hInstance, idCaption, strMsgTitle, ARRAY_SIZE(strMsgTitle));
   else
     strMsgTitle[0] = '\0';
-  LoadStringW(COMDLG32_hInstance, idText, strMsgText, sizeof(strMsgText)/sizeof(WCHAR));
+  LoadStringW(COMDLG32_hInstance, idText, strMsgText, ARRAY_SIZE(strMsgText));
   MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
 }
 
@@ -2351,7 +2546,7 @@ int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf,
                 nOpenAction = ONOPEN_OPEN;
                 break;
             }
-            COMDLG32_SHFree(pidl);
+            ILFree(pidl);
             pidl = NULL;
         }
         else if (!(flags & OFN_NOVALIDATE))
@@ -2383,7 +2578,7 @@ int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf,
             break;
         }
     }
-    if(pidl) COMDLG32_SHFree(pidl);
+    ILFree(pidl);
 
     return nOpenAction;
 }
@@ -2436,7 +2631,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
 */
 
   COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
-  MemFree(lpstrFileList);
+  heap_free(lpstrFileList);
 
 /*
   Step 2: here we have a cleaned up path
@@ -2483,14 +2678,14 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
         DWORD len;
 
         /* replace the current filter */
-        MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
+        heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
         len = lstrlenW(lpszTemp)+1;
-        fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
+        fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc(len * sizeof(WCHAR));
         lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
 
         /* set the filter cb to the extension when possible */
         if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
-        CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);
+        SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, iPos, 0);
       }
       /* fall through */
     case ONOPEN_BROWSE:   /* browse to the highest folder we could bind to */
@@ -2502,7 +2697,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
           LPITEMIDLIST pidlCurrent;
           IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
           IPersistFolder2_Release(ppf2);
-         if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
+          if (!ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
          {
             if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE))
                 && fodInfos->ofnInfos->Flags & OFN_EXPLORER)
@@ -2516,7 +2711,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
             if (fodInfos->Shell.FOIShellView)
               IShellView_Refresh(fodInfos->Shell.FOIShellView);
          }
-          COMDLG32_SHFree(pidlCurrent);
+          ILFree(pidlCurrent);
           if (filename_is_edit( fodInfos ))
               SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
           else
@@ -2560,7 +2755,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
             if (lpstrFilter != (LPWSTR)CB_ERR)  /* control is not empty */
             {
                 WCHAR* filterSearchIndex;
-                filterExt = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
+                filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
                 strcpyW(filterExt, lpstrFilter);
 
                 /* if a semicolon-separated list of file extensions was given, do not include the
@@ -2582,7 +2777,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
                 }
                 else
                 {
-                    HeapFree(GetProcessHeap(), 0, filterExt);
+                    heap_free(filterExt);
                     filterExt = NULL;
                 }
             }
@@ -2590,7 +2785,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
             if (!filterExt)
             {
                 /* use the default file extension */
-                filterExt = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
+                filterExt = heap_alloc((lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
                 strcpyW(filterExt, fodInfos->defext);
             }
 
@@ -2602,7 +2797,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
                 lstrcatW(lpstrPathAndFile, filterExt);
             }
 
-            HeapFree(GetProcessHeap(), 0, filterExt);
+            heap_free(filterExt);
 
             /* In Open dialog: if file does not exist try without extension */
             if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
@@ -2846,28 +3041,6 @@ static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
   }
   return FALSE;
 }
-
-/***********************************************************************
- *      FILEDLG95_SHELL_BrowseToDesktop
- *
- * Browse to the Desktop
- * If the function succeeds, the return value is nonzero.
- */
-static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
-{
-  FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
-  LPITEMIDLIST pidl;
-  HRESULT hres;
-
-  TRACE("\n");
-
-  SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
-  hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
-  if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
-      SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
-  COMDLG32_SHFree(pidl);
-  return SUCCEEDED(hres);
-}
 /***********************************************************************
  *      FILEDLG95_SHELL_Clean
  *
@@ -2879,7 +3052,7 @@ static void FILEDLG95_SHELL_Clean(HWND hwnd)
 
     TRACE("\n");
 
-    COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
+    ILFree(fodInfos->ShellInfos.pidlAbsCurrent);
 
     /* clean Shell interfaces */
     if (fodInfos->Shell.FOIShellView)
@@ -2920,12 +3093,13 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
 
       /* Copy the extensions */
       if (! *lpstrPos) return E_FAIL;  /* malformed filter */
-      if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
+      if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
       lstrcpyW(lpstrExt,lpstrPos);
 
       /* Add the item at the end of the combo */
-      CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->customfilter);
-      CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
+      SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)fodInfos->customfilter);
+      SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters, (LPARAM)lpstrExt);
+
       nFilters++;
   }
   if(fodInfos->filter)
@@ -2946,17 +3120,17 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
       lpstrDisplay = lpstrPos;
       lpstrPos += lstrlenW(lpstrPos) + 1;
 
-      CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
+      SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)lpstrDisplay);
 
       nFilters++;
 
       /* Copy the extensions */
-      if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
+      if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
       lstrcpyW(lpstrExt,lpstrPos);
       lpstrPos += lstrlenW(lpstrPos) + 1;
 
       /* Add the item at the end of the combo */
-      CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters-1, lpstrExt);
+      SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters - 1, (LPARAM)lpstrExt);
 
       /* malformed filters are added anyway... */
       if (!*lpstrExt) break;
@@ -2986,7 +3160,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
       nFilterIndexCB--;
 
     /* Set the current index selection. */
-    CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, nFilterIndexCB);
+    SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, nFilterIndexCB, 0);
 
     /* Get the corresponding text string from the combo box. */
     lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
@@ -3000,7 +3174,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
       DWORD len;
       CharLowerW(lpstrFilter); /* lowercase */
       len = lstrlenW(lpstrFilter)+1;
-      fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
+      fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
       lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
     }
   } else
@@ -3025,14 +3199,14 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
       LPWSTR lpstrFilter;
 
       /* Get the current item of the filetype combo box */
-      int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
+      int iItem = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCURSEL, 0, 0);
 
       /* set the current filter index */
       fodInfos->ofnInfos->nFilterIndex = iItem +
         (fodInfos->customfilter == NULL ? 1 : 0);
 
       /* Set the current filter with the current selection */
-      MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
+      heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
 
       lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
                                              iItem);
@@ -3041,7 +3215,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
           DWORD len;
           CharLowerW(lpstrFilter); /* lowercase */
           len = lstrlenW(lpstrFilter)+1;
-          fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
+          fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
           lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
           if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
               SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
@@ -3061,7 +3235,9 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
  */
 static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt)
 {
-  int i, iCount = CBGetCount(hwnd);
+  int i, iCount;
+
+  iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
 
   TRACE("%s\n", debugstr_w(lpstrExt));
 
@@ -3085,7 +3261,9 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
 {
   FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
   int iPos;
-  int iCount = CBGetCount(fodInfos->DlgInfos.hwndFileTypeCB);
+  int iCount;
+
+  iCount = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCOUNT, 0, 0);
 
   TRACE("\n");
 
@@ -3094,13 +3272,12 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
   {
     for(iPos = iCount-1;iPos>=0;iPos--)
     {
-      MemFree((LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
-      CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
+      heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
+      SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_DELETESTRING, iPos, 0);
     }
   }
   /* Current filter */
-  MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
-
+  heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
 }
 
 /***********************************************************************
@@ -3136,7 +3313,7 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
   LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
   HDC hdc;
   TEXTMETRICW tm;
-  LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos));
+  LookInInfos *liInfos = heap_alloc_zero(sizeof(*liInfos));
 
   TRACE("%p\n", hwndCombo);
 
@@ -3150,16 +3327,16 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
   ReleaseDC( hwndCombo, hdc );
 
   /* set item height for both text field and listbox */
-  CBSetItemHeight( hwndCombo, -1, max( tm.tmHeight, GetSystemMetrics(SM_CYSMICON) ));
-  CBSetItemHeight( hwndCombo, 0, max( tm.tmHeight, GetSystemMetrics(SM_CYSMICON) ));
+  SendMessageW(hwndCombo, CB_SETITEMHEIGHT, -1, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
+  SendMessageW(hwndCombo, CB_SETITEMHEIGHT, 0, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
 
   /* Turn on the extended UI for the combo box like Windows does */
-  CBSetExtendedUI(hwndCombo, TRUE);
+  SendMessageW(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0);
 
   /* Initialise data of Desktop folder */
   SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
   FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
-  COMDLG32_SHFree(pidlTmp);
+  ILFree(pidlTmp);
 
   SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
 
@@ -3178,7 +3355,7 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
        if (!FILEDLG95_unixfs_is_rooted_at_desktop()) 
        {
          /* special handling for CSIDL_DRIVES */
-         if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
+         if (ILIsEqual(pidlTmp, pidlDrives))
          {
            if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
            {
@@ -3187,10 +3364,10 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
              {
                while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
                {
-                 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
+                 pidlAbsTmp = ILCombine(pidlTmp, pidlTmp1);
                  FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
-                 COMDLG32_SHFree(pidlAbsTmp);
-                 COMDLG32_SHFree(pidlTmp1);
+                 ILFree(pidlAbsTmp);
+                 ILFree(pidlTmp1);
                }
                IEnumIDList_Release(lpeDrives);
              }
@@ -3199,14 +3376,14 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
          }
        }
 
-        COMDLG32_SHFree(pidlTmp);
+        ILFree(pidlTmp);
       }
       IEnumIDList_Release(lpeRoot);
     }
     IShellFolder_Release(psfRoot);
   }
 
-  COMDLG32_SHFree(pidlDrives);
+  ILFree(pidlDrives);
 }
 
 /***********************************************************************
@@ -3320,7 +3497,7 @@ static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
       LPSFOLDER tmpFolder;
       int iItem;
 
-      iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
+      iItem = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCURSEL, 0, 0);
 
       if( iItem == CB_ERR) return FALSE;
 
@@ -3365,17 +3542,17 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
   if(!(liInfos = GetPropA(hwnd,LookInInfosStr)))
     return -1;
 
-  tmpFolder = MemAlloc(sizeof(SFOLDER));
+  tmpFolder = heap_alloc_zero(sizeof(*tmpFolder));
   tmpFolder->m_iIndent = 0;
 
   /* Calculate the indentation of the item in the lookin*/
   pidlNext = pidl;
-  while( (pidlNext=COMDLG32_PIDL_ILGetNext(pidlNext)) )
+  while ((pidlNext = ILGetNext(pidlNext)))
   {
     tmpFolder->m_iIndent++;
   }
 
-  tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl);
+  tmpFolder->pidlItem = ILClone(pidl);
 
   if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
     liInfos->iMaxIndentation = tmpFolder->m_iIndent;
@@ -3398,20 +3575,20 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
     /* Add the item at the end of the list */
     if(iInsertId < 0)
     {
-      iItemID = CBAddString(hwnd,sfi.szDisplayName);
+      iItemID = SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)sfi.szDisplayName);
     }
     /* Insert the item at the iInsertId position*/
     else
     {
-      iItemID = CBInsertString(hwnd,sfi.szDisplayName,iInsertId);
+      iItemID = SendMessageW(hwnd, CB_INSERTSTRING, iInsertId, (LPARAM)sfi.szDisplayName);
     }
 
-    CBSetItemDataPtr(hwnd,iItemID,tmpFolder);
+    SendMessageW(hwnd, CB_SETITEMDATA, iItemID, (LPARAM)tmpFolder);
     return iItemID;
   }
 
-  COMDLG32_SHFree( tmpFolder->pidlItem );
-  MemFree( tmpFolder );
+  ILFree( tmpFolder->pidlItem );
+  heap_free( tmpFolder );
   return -1;
 
 }
@@ -3439,8 +3616,7 @@ static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
     iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
   }
 
-  /* Free pidlParent memory */
-  COMDLG32_SHFree(pidlParent);
+  ILFree(pidlParent);
 
   return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
 }
@@ -3482,7 +3658,7 @@ int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl)
     }
   }
 
-  CBSetCurSel(hwnd,iItemPos);
+  SendMessageW(hwnd, CB_SETCURSEL, iItemPos, 0);
   liInfos->uSelectedItem = iItemPos;
 
   return 0;
@@ -3507,9 +3683,9 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
   if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
   {
     SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
-    COMDLG32_SHFree(tmpFolder->pidlItem);
-    MemFree(tmpFolder);
-    CBDeleteString(hwnd,iItemPos);
+    ILFree(tmpFolder->pidlItem);
+    heap_free(tmpFolder);
+    SendMessageW(hwnd, CB_DELETESTRING, iItemPos, 0);
     liInfos->iMaxIndentation--;
 
     return iItemPos;
@@ -3527,7 +3703,9 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
 static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod)
 {
   int i = 0;
-  int iCount = CBGetCount(hwnd);
+  int iCount;
+
+  iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
 
   TRACE("0x%08lx 0x%x\n",searchArg, iSearchMethod);
 
@@ -3537,7 +3715,7 @@ static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMet
     {
       LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
 
-      if(iSearchMethod == SEARCH_PIDL && COMDLG32_PIDL_ILIsEqual((LPITEMIDLIST)searchArg,tmpFolder->pidlItem))
+      if (iSearchMethod == SEARCH_PIDL && ILIsEqual((LPITEMIDLIST)searchArg, tmpFolder->pidlItem))
         return i;
       if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
         return i;
@@ -3556,8 +3734,9 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
 {
     FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
     LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
-    int iPos;
-    int iCount = CBGetCount(fodInfos->DlgInfos.hwndLookInCB);
+    int iPos, iCount;
+
+    iCount = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCOUNT, 0, 0);
 
     TRACE("\n");
 
@@ -3567,14 +3746,14 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
       for(iPos = iCount-1;iPos>=0;iPos--)
       {
         SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
-        COMDLG32_SHFree(tmpFolder->pidlItem);
-        MemFree(tmpFolder);
-        CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos);
+        ILFree(tmpFolder->pidlItem);
+        heap_free(tmpFolder);
+        SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_DELETESTRING, iPos, 0);
       }
     }
 
     /* LookInInfos structure */
-    MemFree(liInfos);
+    heap_free(liInfos);
     RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
 }
 
@@ -3622,7 +3801,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
 
     /* Allocate a buffer */
     nAllFilesMaxLength = MAX_PATH + 3;
-    lpstrAllFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nAllFilesMaxLength * sizeof(WCHAR));
+    lpstrAllFiles = heap_alloc_zero(nAllFilesMaxLength * sizeof(WCHAR));
     if (!lpstrAllFiles)
         goto ret;
 
@@ -3669,7 +3848,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
     }
 
 ret:
-    HeapFree(GetProcessHeap(), 0, lpstrAllFiles);
+    heap_free(lpstrAllFiles);
     COMCTL32_ReleaseStgMedium(medium);
 }
 
@@ -3684,7 +3863,7 @@ static HRESULT COMDLG32_StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, con
        {
          case STRRET_WSTR:
            lstrcpynW(dest, src->u.pOleStr, len);
-           COMDLG32_SHFree(src->u.pOleStr);
+           CoTaskMemFree(src->u.pOleStr);
            break;
 
          case STRRET_CSTR:
@@ -3721,13 +3900,13 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U
 
        /* get the filenames from the filename control */
        nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName );
-       lpstrEdit = MemAlloc( (nStrLen+1)*sizeof(WCHAR) );
+       lpstrEdit = heap_alloc( (nStrLen+1)*sizeof(WCHAR) );
        GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1);
 
        TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
 
        nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed);
-       MemFree(lpstrEdit);
+       heap_free(lpstrEdit);
        return nFileCount;
 }
 
@@ -3778,7 +3957,7 @@ LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
       LPIDA cida = GlobalLock(medium.u.hGlobal);
       if(nPidlIndex <= cida->cidl)
       {
-        pidl = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
+        pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
       }
       COMCTL32_ReleaseStgMedium(medium);
     }
@@ -3889,8 +4068,8 @@ LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
 
   TRACE("%p\n", pidl);
 
-  pidlParent = COMDLG32_PIDL_ILClone(pidl);
-  COMDLG32_PIDL_ILRemoveLastID(pidlParent);
+  pidlParent = ILClone(pidl);
+  ILRemoveLastID(pidlParent);
 
   return pidlParent;
 }
@@ -3963,31 +4142,19 @@ static BOOL BrowseSelectedFolder(HWND hwnd)
                          pidlSelection, SBSP_RELATIVE ) ) )
           {
                WCHAR buf[64];
-               LoadStringW( COMDLG32_hInstance, IDS_PATHNOTEXISTING, buf, sizeof(buf)/sizeof(WCHAR) );
+               LoadStringW( COMDLG32_hInstance, IDS_PATHNOTEXISTING, buf, ARRAY_SIZE(buf));
                MessageBoxW( hwnd, buf, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
           }
           bBrowseSelFolder = TRUE;
           if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
               SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
       }
-      COMDLG32_SHFree( pidlSelection );
+      ILFree( pidlSelection );
   }
 
   return bBrowseSelFolder;
 }
 
-/*
- * Memory allocation methods */
-static void *MemAlloc(UINT size)
-{
-    return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
-}
-
-static void MemFree(void *mem)
-{
-    HeapFree(GetProcessHeap(),0,mem);
-}
-
 static inline BOOL valid_struct_size( DWORD size )
 {
     return (size == OPENFILENAME_SIZE_VERSION_400W) ||
@@ -4144,11 +4311,11 @@ short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
     LPWSTR lpWTitle;
 
     RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
-    lpWTitle = RtlAllocateHeap( GetProcessHeap(), 0, cbBuf*sizeof(WCHAR));
+    lpWTitle = heap_alloc(cbBuf * sizeof(WCHAR));
     ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
     if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
     RtlFreeUnicodeString( &strWFile );
-    RtlFreeHeap( GetProcessHeap(), 0, lpWTitle );
+    heap_free( lpWTitle );
     return ret;
 }
 
index 0409915..76ac503 100644 (file)
@@ -30,6 +30,7 @@
 #include "winuser.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 #include "winreg.h"
 #include "winternl.h"
 #include "commdlg.h"
@@ -105,7 +106,7 @@ static void FD31_StripEditControl(HWND hwnd)
 {
     WCHAR temp[BUFFILE], *cp;
 
-    GetDlgItemTextW( hwnd, edt1, temp, sizeof(temp)/sizeof(WCHAR));
+    GetDlgItemTextW( hwnd, edt1, temp, ARRAY_SIZE(temp));
     cp = strrchrW(temp, '\\');
     if (cp != NULL) {
        strcpyW(temp, cp+1);
@@ -231,7 +232,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
 
     if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
     {
-        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
+        if (!(str = heap_alloc(BUFFILEALLOC))) return FALSE;
        SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
                       (LPARAM)str);
 
@@ -255,13 +256,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
            SetBkColor( lpdis->hDC, oldBk );
            SetTextColor( lpdis->hDC, oldText );
        }
-        HeapFree(GetProcessHeap(), 0, str);
+        heap_free(str);
        return TRUE;
     }
 
     if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
     {
-        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
+        if (!(str = heap_alloc(BUFFILEALLOC)))
             return FALSE;
        SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
                       (LPARAM)str);
@@ -284,13 +285,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
            SetTextColor( lpdis->hDC, oldText );
        }
        DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL );
-        HeapFree(GetProcessHeap(), 0, str);
+        heap_free(str);
        return TRUE;
     }
     if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
     {
         char root[] = "a:";
-        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
+        if (!(str = heap_alloc(BUFFILEALLOC)))
             return FALSE;
        SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
                       (LPARAM)str);
@@ -318,7 +319,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
            SetTextColor( lpdis->hDC, oldText );
        }
        DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon, 16, 16, 0, 0, DI_NORMAL );
-        HeapFree(GetProcessHeap(), 0, str);
+        heap_free(str);
        return TRUE;
     }
     return FALSE;
@@ -418,11 +419,11 @@ static LRESULT FD31_DirListDblClick( const FD31_DATA *lfs )
   /* get the raw string (with brackets) */
   lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
   if (lRet == LB_ERR) return TRUE;
-  pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
+  pstr = heap_alloc(BUFFILEALLOC);
   SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
                     (LPARAM)pstr);
   strcpyW( tmpstr, pstr );
-  HeapFree(GetProcessHeap(), 0, pstr);
+  heap_free(pstr);
   /* get the selected directory in tmpstr */
   if (tmpstr[0] == '[')
     {
@@ -457,12 +458,12 @@ static LRESULT FD31_FileListSelect( const FD31_DATA *lfs )
         return TRUE;
 
     /* set the edit control to the chosen file */
-    if ((pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
+    if ((pstr = heap_alloc(BUFFILEALLOC)))
     {
         SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
                        (LPARAM)pstr);
         SetDlgItemTextW( hWnd, edt1, pstr );
-        HeapFree(GetProcessHeap(), 0, pstr);
+        heap_free(pstr);
     }
     if (lfs->hook)
     {
@@ -531,7 +532,7 @@ static LRESULT FD31_TestPath( const FD31_DATA *lfs, LPWSTR path )
         *pBeginFileName = 0;
         SetDlgItemTextW( hWnd, edt1, pBeginFileName + 1 );
 
-        lstrcpynW(tmpstr2, pBeginFileName + 1, sizeof(tmpstr2)/sizeof(WCHAR) );
+        lstrcpynW(tmpstr2, pBeginFileName + 1, ARRAY_SIZE(tmpstr2));
         /* Should we MessageBox() if this fails? */
         if (!FD31_ScanDir(lfs->ofnW, hWnd, path))
         {
@@ -562,9 +563,9 @@ static LRESULT FD31_Validate( const FD31_DATA *lfs, LPCWSTR path, UINT control,
 
     /* get current file name */
     if (path)
-        lstrcpynW(filename, path, sizeof(filename)/sizeof(WCHAR));
+        lstrcpynW(filename, path, ARRAY_SIZE(filename));
     else
-        GetDlgItemTextW( hWnd, edt1, filename, sizeof(filename)/sizeof(WCHAR));
+        GetDlgItemTextW( hWnd, edt1, filename, ARRAY_SIZE(filename));
 
     TRACE("got filename = %s\n", debugstr_w(filename));
     /* if we did not click in file list to get there */
@@ -624,11 +625,11 @@ static LRESULT FD31_DiskChange( const FD31_DATA *lfs )
     lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
     if (lRet == LB_ERR)
         return 0;
-    pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
+    pstr = heap_alloc(BUFFILEALLOC);
     SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
                          (LPARAM)pstr);
     wsprintfW(diskname, FILE_specc, pstr[2]);
-    HeapFree(GetProcessHeap(), 0, pstr);
+    heap_free(pstr);
 
     return FD31_Validate( lfs, diskname, cmb2, lRet, TRUE );
 }
@@ -729,7 +730,7 @@ static LPWSTR FD31_MapStringPairsToW(LPCSTR strA, UINT size)
     if (n < size) n = size;
 
     len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
-    x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR));
+    x = heap_alloc(len * sizeof(WCHAR));
     MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
     return x;
 }
@@ -744,7 +745,7 @@ static LPWSTR FD31_DupToW(LPCSTR str, DWORD size)
     LPWSTR strW = NULL;
     if (str && (size > 0))
     {
-        strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
+        strW = heap_alloc(size * sizeof(WCHAR));
         if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
     }
     return strW;
@@ -783,10 +784,9 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW,
         WCHAR buf[16];
         LPWSTR title_tmp;
         int len;
-        LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS,
-                    buf, sizeof(buf)/sizeof(WCHAR));
+        LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS, buf, ARRAY_SIZE(buf));
         len = lstrlenW(buf)+1;
-        title_tmp = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+        title_tmp = heap_alloc(len * sizeof(WCHAR));
         memcpy(title_tmp, buf, len * sizeof(WCHAR));
         ofnW->lpstrTitle = title_tmp;
     }
@@ -819,14 +819,14 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW,
  */
 static void FD31_FreeOfnW(OPENFILENAMEW *ofnW)
 {
-   HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
-   HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter);
-   HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile);
-   HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
-   HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
-   HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
-   if (!IS_INTRESOURCE(ofnW->lpTemplateName))
-       HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
+    heap_free((void *)ofnW->lpstrFilter);
+    heap_free(ofnW->lpstrCustomFilter);
+    heap_free(ofnW->lpstrFile);
+    heap_free(ofnW->lpstrFileTitle);
+    heap_free((void *)ofnW->lpstrInitialDir);
+    heap_free((void *)ofnW->lpstrTitle);
+    if (!IS_INTRESOURCE(ofnW->lpTemplateName))
+        heap_free((void *)ofnW->lpTemplateName);
 }
 
 /************************************************************************
@@ -844,9 +844,9 @@ static void FD31_DestroyPrivate(PFD31_DATA lfs)
     if (lfs->ofnA)
     {
         FD31_FreeOfnW(lfs->ofnW);
-        HeapFree(GetProcessHeap(), 0, lfs->ofnW);
+        heap_free(lfs->ofnW);
     }
-    HeapFree(GetProcessHeap(), 0, lfs);
+    heap_free(lfs);
     RemovePropA(hwnd, FD31_OFN_PROP);
 }
 
@@ -918,7 +918,7 @@ static BOOL FD31_GetTemplate(PFD31_DATA lfs)
  */
 static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
 {
-    PFD31_DATA lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FD31_DATA));
+    FD31_DATA *lfs = heap_alloc_zero(sizeof(*lfs));
 
     TRACE("alloc private buf %p\n", lfs);
     if (!lfs) return NULL;
@@ -940,7 +940,7 @@ static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
         if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
             if (lfs->ofnA->lpfnHook)
                 lfs->hook = TRUE;
-        lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lfs->ofnA->lStructSize);
+        lfs->ofnW = heap_alloc_zero(lfs->ofnA->lStructSize);
         lfs->ofnW->lStructSize = lfs->ofnA->lStructSize;
         FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
     }
index a225e9e..5b5323f 100644 (file)
@@ -40,6 +40,7 @@
 #include "shlguid.h"
 #include "servprov.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
@@ -116,7 +117,7 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags)
         };
 #undef FE
         TRACE("SBSP Flags: %08x =", uflags);
-       for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
            if (flags[i].mask & uflags)
                TRACE("%s ", flags[i].name);
        TRACE("\n");
@@ -155,7 +156,7 @@ static BOOL COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITE
        {
          case STRRET_WSTR:
             lstrcpynW(dest, src->u.pOleStr, len);
-           COMDLG32_SHFree(src->u.pOleStr);
+           CoTaskMemFree(src->u.pOleStr);
            break;
 
          case STRRET_CSTR:
@@ -194,7 +195,7 @@ IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
     FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndOwner);
     IShellBrowserImpl *sb;
 
-    sb = COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
+    sb = heap_alloc(sizeof(*sb));
 
     /* Initialisation of the member variables */
     sb->ref=1;
@@ -267,10 +268,8 @@ static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
     TRACE("(%p,%u)\n", This, ref + 1);
 
     if (!ref)
-    {
-      COMDLG32_SHFree(This);
-      TRACE("-- destroyed\n");
-    }
+        heap_free(This);
+
     return ref;
 }
 
@@ -335,7 +334,7 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
                                               UINT wFlags)
 {
     HRESULT hRes;
-    IShellFolder *psfTmp;
+    IShellFolder *folder;
     IShellView *psvTmp;
     FileOpenDlgInfos *fodInfos;
     LPITEMIDLIST pidlTmp;
@@ -356,43 +355,43 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     {
 
         /* SBSP_RELATIVE  A relative pidl (relative from the current folder) */
-        if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
-             pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
+        if (FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
+             pidl, NULL, &IID_IShellFolder, (void **)&folder)))
         {
             ERR("bind to object failed\n");
            return hRes;
         }
         /* create an absolute pidl */
-        pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, pidl);
+        pidlTmp = ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, pidl);
     }
     else if(wFlags & SBSP_PARENT)
     {
         /* Browse the parent folder (ignores the pidl) */
         pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
-        psfTmp = GetShellFolderFromPidl(pidlTmp);
-
+        folder = GetShellFolderFromPidl(pidlTmp);
     }
     else /* SBSP_ABSOLUTE is 0x0000 */
     {
         /* An absolute pidl (relative from the desktop) */
-        pidlTmp =  COMDLG32_PIDL_ILClone(pidl);
-        psfTmp = GetShellFolderFromPidl(pidlTmp);
+        pidlTmp = ILClone(pidl);
+        folder = GetShellFolderFromPidl(pidlTmp);
     }
 
-    if(!psfTmp)
+    if (!folder)
     {
-      ERR("could not browse to folder\n");
-      return E_FAIL;
+        ERR("could not browse to folder\n");
+        ILFree(pidlTmp);
+        return E_FAIL;
     }
 
     /* If the pidl to browse to is equal to the actual pidl ...
        do nothing and pretend you did it*/
-    if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
+    if (ILIsEqual(pidlTmp, fodInfos->ShellInfos.pidlAbsCurrent))
     {
-        IShellFolder_Release(psfTmp);
-       COMDLG32_SHFree(pidlTmp);
+        IShellFolder_Release(folder);
+        ILFree(pidlTmp);
         TRACE("keep current folder\n");
-        return NOERROR;
+        return S_OK;
     }
 
     /* Release the current DataObject */
@@ -404,8 +403,13 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
 
     /* Create the associated view */
     TRACE("create view object\n");
-    if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
-           &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
+    if (FAILED(hRes = IShellFolder_CreateViewObject(folder, fodInfos->ShellInfos.hwndOwner,
+           &IID_IShellView, (void **)&psvTmp)))
+    {
+        IShellFolder_Release(folder);
+        ILFree(pidlTmp);
+        return hRes;
+    }
 
     /* Check if listview has focus */
     bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
@@ -427,10 +431,10 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     /* Release old FOIShellFolder and update its value */
     if (fodInfos->Shell.FOIShellFolder)
       IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
-    fodInfos->Shell.FOIShellFolder = psfTmp;
+    fodInfos->Shell.FOIShellFolder = folder;
 
     /* Release old pidlAbsCurrent and update its value */
-    COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
+    ILFree(fodInfos->ShellInfos.pidlAbsCurrent);
     fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
 
     COMDLG32_UpdateCurrentDir(fodInfos);
@@ -440,9 +444,13 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
 
     /* Create the window */
     TRACE("create view window\n");
-    if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
-         &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
-         &rectView, &hwndView))) goto error;
+    if (FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
+            &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
+            &rectView, &hwndView)))
+    {
+        WARN("Failed to create view window, hr %#x.\n", hRes);
+        return hRes;
+    }
 
     fodInfos->ShellInfos.hwndView = hwndView;
 
@@ -462,9 +470,6 @@ static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
       SetFocus(fodInfos->ShellInfos.hwndView);
 
     return hRes;
-error:
-    ERR("Failed with error 0x%08x\n", hRes);
-    return hRes;
 }
 
 /**************************************************************************
@@ -784,8 +789,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDl
          hRes = S_OK;
        }
 
-        /* Free memory used by pidl */
-        COMDLG32_SHFree(pidl);
+        ILFree(pidl);
 
         return hRes;
     }
@@ -847,7 +851,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBr
                if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
                {
                    WCHAR szSave[16];
-                   LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, szSave, sizeof(szSave)/sizeof(WCHAR));
+                   LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, szSave, ARRAY_SIZE(szSave));
                    SetDlgItemTextW(fodInfos->ShellInfos.hwndOwner, IDOK, szSave);
                }
             }
index 5cb5435..21eb3d5 100644 (file)
@@ -93,6 +93,7 @@ typedef struct
     } HookMsg;
 
     BOOL ole_initialized;
+    LPITEMIDLIST places[5];
 } FileOpenDlgInfos;
 
 /***********************************************************************
@@ -131,6 +132,7 @@ typedef struct
 #define IDC_FILENAME                    edt1
 
 #define IDC_TOOLBAR                    1
+#define IDC_TOOLBARPLACES               ctl1
 
 /***********************************************************************
  * Prototypes for the methods of the IShellBrowserImpl class
index bc4a31c..d769325 100644 (file)
@@ -30,6 +30,7 @@
 #include "cderr.h"
 #include "dlgs.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
@@ -284,7 +285,7 @@ static INT_PTR CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPA
         if(iMsg == WM_DESTROY)
         {
                RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
-               HeapFree(GetProcessHeap(), 0, pdata);
+               heap_free(pdata);
         }
 
         return retval;
@@ -427,7 +428,7 @@ static HWND COMDLG32_FR_DoFindReplace(
                error = CDERR_DIALOGFAILURE;
 cleanup:
                COMDLG32_SetCommDlgExtendedError(error);
-                HeapFree(GetProcessHeap(), 0, pdata);
+                heap_free(pdata);
         }
         return hdlgwnd;
 }
index 768ca4a..9f9f48a 100644 (file)
@@ -32,6 +32,7 @@
 #include "commdlg.h"
 #include "dlgs.h"
 #include "wine/debug.h"
+#include "wine/heap.h"
 #include "wine/unicode.h"
 #include "cderr.h"
 #include "cdlg.h"
@@ -162,7 +163,7 @@ static void _dump_cf_flags(DWORD cflags)
 {
     unsigned int i;
 
-    for (i = 0; i < sizeof(cfflags)/sizeof(cfflags[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(cfflags); i++)
         if (cfflags[i].mask & cflags)
             TRACE("%s|",cfflags[i].name);
     TRACE("\n");
@@ -442,7 +443,7 @@ static BOOL SetFontSizesToCombo3(HWND hwnd, const CHOOSEFONTW *lpcf)
     static const BYTE sizes[]={6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
     unsigned int i;
 
-    for (i = 0; i < sizeof(sizes)/sizeof(sizes[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(sizes); i++)
         if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return TRUE;
     return FALSE;
 }
@@ -663,7 +664,7 @@ static LRESULT CFn_WMInitDialog(HWND hDlg, LPARAM lParam, LPCHOOSEFONTW lpcf)
             WCHAR name[30];
 
             if( LoadStringW(COMDLG32_hInstance, IDS_COLOR_BLACK+i, name,
-                        sizeof(name)/sizeof(*name) )==0 )
+                        ARRAY_SIZE(name)) == 0 )
             {
                 memcpy(name, strColorName, sizeof(strColorName));
             }
@@ -903,7 +904,7 @@ static INT get_dialog_font_point_size(HWND hDlg, CHOOSEFONTW *cf)
     {
         WCHAR buffW[8], *endptrW;
 
-        GetDlgItemTextW(hDlg, cmb3, buffW, sizeof(buffW)/sizeof(*buffW));
+        GetDlgItemTextW(hDlg, cmb3, buffW, ARRAY_SIZE(buffW));
         size = strtolW(buffW, &endptrW, 10);
         invalid_size = size == 0 && *endptrW;
 
@@ -934,7 +935,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
         WCHAR str_edit[256], str_cmb[256];
         int cmb = LOWORD(wParam);
 
-        GetDlgItemTextW(hDlg, cmb, str_edit, sizeof(str_edit) / sizeof(str_edit[0]));
+        GetDlgItemTextW(hDlg, cmb, str_edit, ARRAY_SIZE(str_edit));
         idx = SendDlgItemMessageW(hDlg, cmb, CB_FINDSTRING, -1, (LPARAM)str_edit);
         if(idx != -1)
         {
@@ -1016,7 +1017,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
             /* face name */
             i=SendDlgItemMessageW(hDlg,cmb1,CB_GETCURSEL,0,0);
             if (i==CB_ERR)
-                GetDlgItemTextW( hDlg, cmb1, str, sizeof(str)/sizeof(str[0]) );
+                GetDlgItemTextW( hDlg, cmb1, str, ARRAY_SIZE(str));
             else
             {
                 SendDlgItemMessageW(hDlg,cmb1,CB_GETLBTEXT,i,
@@ -1028,7 +1029,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
                    call back with the extra FONTTYPE_...  bits added */
                 lpxx->lfPitchAndFamily = HIWORD(l) >> 8;
             }
-            lstrcpynW(lpxx->lfFaceName, str, sizeof(lpxx->lfFaceName)/sizeof(lpxx->lfFaceName[0]));
+            lstrcpynW(lpxx->lfFaceName, str, ARRAY_SIZE(lpxx->lfFaceName));
 
             /* style */
             i=SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
@@ -1098,7 +1099,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
         pointsize = get_dialog_font_point_size(hDlg, lpcf);
         if (pointsize == -1)
         {
-            LoadStringW(COMDLG32_hInstance, IDS_FONT_SIZE_INPUT, msgW, sizeof(msgW)/sizeof(*msgW));
+            LoadStringW(COMDLG32_hInstance, IDS_FONT_SIZE_INPUT, msgW, ARRAY_SIZE(msgW));
             MessageBoxW(hDlg, msgW, NULL, MB_OK | MB_ICONINFORMATION);
             return TRUE;
         }
@@ -1112,11 +1113,11 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
         {
             WCHAR format[80];
             DWORD_PTR args[2];
-            LoadStringW(COMDLG32_hInstance, IDS_FONT_SIZE, format, sizeof(format)/sizeof(WCHAR));
+            LoadStringW(COMDLG32_hInstance, IDS_FONT_SIZE, format, ARRAY_SIZE(format));
             args[0] = lpcf->nSizeMin;
             args[1] = lpcf->nSizeMax;
             FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                           format, 0, 0, msgW, sizeof(msgW)/sizeof(*msgW),
+                           format, 0, 0, msgW, ARRAY_SIZE(msgW),
                            (__ms_va_list*)args);
             MessageBoxW(hDlg, msgW, NULL, MB_OK);
         }
@@ -1151,11 +1152,11 @@ static LRESULT CFn_WMDestroy(HWND hwnd, LPCHOOSEFONTW lpcfw)
     if((lpcfw->Flags & CF_USESTYLE) && lpcfw->lpszStyle) {
         len = WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, NULL, 0, 0, 0);
         WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, lpcfa->lpszStyle, len, 0, 0);
-        HeapFree(GetProcessHeap(), 0, lpcfw->lpszStyle);
+        heap_free(lpcfw->lpszStyle);
     }
 
-    HeapFree(GetProcessHeap(), 0, lpcfw->lpLogFont);
-    HeapFree(GetProcessHeap(), 0, lpcfw);
+    heap_free(lpcfw->lpLogFont);
+    heap_free(lpcfw);
     SetPropW(hwnd, strWineFontData, 0);
 
     return TRUE;
@@ -1217,16 +1218,16 @@ static INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
         lpcfa=(LPCHOOSEFONTA)lParam;
         SetPropW(hDlg, strWineFontData_a, (HANDLE)lParam);
 
-        lpcfw = HeapAlloc(GetProcessHeap(), 0, sizeof(CHOOSEFONTW));
+        lpcfw = heap_alloc(sizeof(*lpcfw));
         memcpy(lpcfw, lpcfa, sizeof(CHOOSEFONTA));
-        lpcfw->lpLogFont = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGFONTW));
+        lpcfw->lpLogFont = heap_alloc(sizeof(*lpcfw->lpLogFont));
         memcpy(lpcfw->lpLogFont, lpcfa->lpLogFont, sizeof(LOGFONTA));
         MultiByteToWideChar(CP_ACP, 0, lpcfa->lpLogFont->lfFaceName,
                             LF_FACESIZE, lpcfw->lpLogFont->lfFaceName, LF_FACESIZE);
 
         if((lpcfa->Flags & CF_USESTYLE) && lpcfa->lpszStyle)  {
             len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, NULL, 0);
-            lpcfw->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+            lpcfw->lpszStyle = heap_alloc(len * sizeof(WCHAR));
             MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, lpcfw->lpszStyle, len);
         }
 
index 2b7a6fe..f1f0492 100644 (file)
@@ -659,7 +659,7 @@ static HRESULT on_default_action(FileDialogImpl *This)
                 if(hr != S_OK)
                 {
                     WCHAR buf[64];
-                    LoadStringW(COMDLG32_hInstance, IDS_INVALID_FOLDERNAME, buf, sizeof(buf)/sizeof(WCHAR));
+                    LoadStringW(COMDLG32_hInstance, IDS_INVALID_FOLDERNAME, buf, ARRAY_SIZE(buf));
 
                     MessageBoxW(This->dlg_hwnd, buf, This->custom_title, MB_OK | MB_ICONEXCLAMATION);
 
@@ -2510,7 +2510,7 @@ static HRESULT WINAPI IFileDialog2_fnSetOptions(IFileDialog2 *iface, FILEOPENDIA
     if( !(This->options & FOS_PICKFOLDERS) && (fos & FOS_PICKFOLDERS) )
     {
         WCHAR buf[30];
-        LoadStringW(COMDLG32_hInstance, IDS_SELECT_FOLDER, buf, sizeof(buf)/sizeof(WCHAR));
+        LoadStringW(COMDLG32_hInstance, IDS_SELECT_FOLDER, buf, ARRAY_SIZE(buf));
         IFileDialog2_SetTitle(iface, buf);
     }
 
@@ -4625,7 +4625,7 @@ static HRESULT FileDialog_constructor(IUnknown *pUnkOuter, REFIID riid, void **p
         fdimpl->u.IFileSaveDialog_iface.lpVtbl = &vt_IFileSaveDialog;
         fdimpl->options = FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN | FOS_PATHMUSTEXIST | FOS_NOCHANGEDIR;
 
-        LoadStringW(COMDLG32_hInstance, IDS_SAVE, buf, sizeof(buf)/sizeof(WCHAR));
+        LoadStringW(COMDLG32_hInstance, IDS_SAVE, buf, ARRAY_SIZE(buf));
         fdimpl->custom_title = StrDupW(buf);
         fdimpl->custom_okbutton = StrDupW(buf);
     }
index 0f5a934..c108058 100644 (file)
@@ -32,6 +32,7 @@
 #define NO_SHLWAPI_STREAM
 #include <shlwapi.h>
 
+#include <wine/heap.h>
 #include <wine/unicode.h>
 #include <wine/debug.h>
 
index 83335a9..429903b 100644 (file)
@@ -369,7 +369,7 @@ static DEVMODEA *convert_to_devmodeA(const DEVMODEW *dmW)
 static BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
 {
     WCHAR buf[260];
-    DWORD dwBufLen = sizeof(buf) / sizeof(buf[0]);
+    DWORD dwBufLen = ARRAY_SIZE(buf);
     BOOL res;
     if(!GetDefaultPrinterW(buf, &dwBufLen))
         return FALSE;
@@ -414,7 +414,7 @@ static INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name)
                                (LPARAM)name)) == CB_ERR) {
 
         char buf[260];
-        DWORD dwBufLen = sizeof(buf);
+        DWORD dwBufLen = ARRAY_SIZE(buf);
         if (name != NULL)
             WARN("Can't find %s in printer list so trying to find default\n",
                debugstr_a(name));
@@ -447,7 +447,7 @@ static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
        (i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1,
                                (LPARAM)name)) == CB_ERR) {
         WCHAR buf[260];
-        DWORD dwBufLen = sizeof(buf)/sizeof(buf[0]);
+        DWORD dwBufLen = ARRAY_SIZE(buf);
         if (name != NULL)
             WARN("Can't find %s in printer list so trying to find default\n",
                debugstr_w(name));
@@ -477,7 +477,7 @@ static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, const char* DeviceDriverName,
     char*   pTempPtr;
     LPDEVNAMES lpDevNames;
     char buf[260];
-    DWORD dwBufLen = sizeof(buf);
+    DWORD dwBufLen = ARRAY_SIZE(buf);
     const char *p;
 
     p = strrchr( DeviceDriverName, '\\' );
@@ -524,7 +524,7 @@ static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName,
     LPWSTR   pTempPtr;
     LPDEVNAMES lpDevNames;
     WCHAR bufW[260];
-    DWORD dwBufLen = sizeof(bufW) / sizeof(WCHAR);
+    DWORD dwBufLen = ARRAY_SIZE(bufW);
     const WCHAR *p;
 
     p = strrchrW( DeviceDriverName, '\\' );
@@ -715,7 +715,7 @@ static BOOL PRINTDLG_UpdatePrintDlgW(HWND hDlg,
                 args[1] = lppd->nMaxPage;
                 FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                resourcestr, 0, 0, resultstr,
-                               sizeof(resultstr)/sizeof(*resultstr),
+                               ARRAY_SIZE(resultstr),
                                (__ms_va_list*)args);
                LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE,
                            resourcestr, 255);
@@ -1559,7 +1559,7 @@ static LRESULT PRINTDLG_WMInitDialog(HWND hDlg,
     } else {
        /* else use default printer */
        char name[200];
-        DWORD dwBufLen = sizeof(name);
+        DWORD dwBufLen = ARRAY_SIZE(name);
        BOOL ret = GetDefaultPrinterA(name, &dwBufLen);
 
        if (ret)
@@ -1668,7 +1668,7 @@ static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg,
     } else {
        /* else use default printer */
        WCHAR name[200];
-        DWORD dwBufLen = sizeof(name) / sizeof(WCHAR);
+        DWORD dwBufLen = ARRAY_SIZE(name);
        BOOL ret = GetDefaultPrinterW(name, &dwBufLen);
 
        if (ret)
@@ -2610,7 +2610,7 @@ static WCHAR get_decimal_sep(void)
     if(!sep)
     {
         WCHAR buf[] = {'.', 0};
-        GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buf, sizeof(buf) / sizeof(buf[0]));
+        GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buf, ARRAY_SIZE(buf));
         sep = buf[0];
     }
     return sep;
@@ -2869,7 +2869,7 @@ static void pagesetup_set_devnames(pagesetup_data *data, LPCWSTR drv, LPCWSTR de
     }
 
     dn->wDefault = 0;
-    len = sizeof(def) / sizeof(def[0]);
+    len = ARRAY_SIZE(def);
     GetDefaultPrinterW(def, &len);
     if(!lstrcmpW(def, devname))
         dn->wDefault = 1;
@@ -3243,7 +3243,7 @@ static void margin_edit_notification(HWND hDlg, const pagesetup_data *data, WORD
         LONG val = 0;
         LONG *value = element_from_margin_id(pagesetup_get_margin_rect(data), id);
 
-        if (GetDlgItemTextW(hDlg, id, buf, sizeof(buf) / sizeof(buf[0])) != 0)
+        if (GetDlgItemTextW(hDlg, id, buf, ARRAY_SIZE(buf)) != 0)
         {
             WCHAR *end;
             WCHAR decimal = get_decimal_sep();
@@ -3282,7 +3282,7 @@ static void set_margin_groupbox_title(HWND hDlg, const pagesetup_data *data)
     WCHAR title[256];
 
     if(LoadStringW(COMDLG32_hInstance, is_metric(data) ? PD32_MARGINS_IN_MILLIMETERS : PD32_MARGINS_IN_INCHES,
-                   title, sizeof(title)/sizeof(title[0])))
+                   title, ARRAY_SIZE(title)))
         SetDlgItemTextW(hDlg, grp4, title);
 }
 
@@ -3486,7 +3486,7 @@ static UINT_PTR default_page_paint_hook(HWND hwndDlg, UINT uMsg, WPARAM wParam,
                  LoadStringW(COMDLG32_hInstance,
                         IDS_FAKEDOCTEXT,
                         wszFakeDocumentText,
-                        sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));
+                        ARRAY_SIZE(wszFakeDocumentText));
 
             oldbkmode = SetBkMode(hdc, TRANSPARENT);
             DrawTextW(hdc, wszFakeDocumentText, -1, lprc, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);
index 65532cc..44573b5 100644 (file)
@@ -55,7 +55,7 @@ reactos/dll/win32/cabinet             # Synced to WineStaging-3.3
 reactos/dll/win32/clusapi             # Synced to WineStaging-3.3
 reactos/dll/win32/comcat              # Synced to WineStaging-3.3
 reactos/dll/win32/comctl32            # Synced to Wine-3.0
-reactos/dll/win32/comdlg32            # Synced to WineStaging-3.3
+reactos/dll/win32/comdlg32            # Synced to WineStaging-3.9
 reactos/dll/win32/compstui            # Synced to WineStaging-3.3
 reactos/dll/win32/credui              # Synced to WineStaging-3.3
 reactos/dll/win32/crypt32             # Synced to WineStaging-3.3