Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comdlg32/cdlg32.c | 22 ++++---- dlls/comdlg32/colordlg.c | 17 +++--- dlls/comdlg32/filedlg.c | 140 ++++++++++++++++++++-------------------------- dlls/comdlg32/filedlg31.c | 55 +++++++++--------- dlls/comdlg32/finddlg.c | 5 +- dlls/comdlg32/fontdlg.c | 13 +++-- 6 files changed, 122 insertions(+), 130 deletions(-)
diff --git a/dlls/comdlg32/cdlg32.c b/dlls/comdlg32/cdlg32.c index e794f94d8b..a00da2dda7 100644 --- a/dlls/comdlg32/cdlg32.c +++ b/dlls/comdlg32/cdlg32.c @@ -32,6 +32,7 @@ #include "commdlg.h" #include "cderr.h" #include "wine/debug.h" +#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
@@ -128,16 +129,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; }
diff --git a/dlls/comdlg32/colordlg.c b/dlls/comdlg32/colordlg.c index bead9ba38c..a717e847c7 100644 --- a/dlls/comdlg32/colordlg.c +++ b/dlls/comdlg32/colordlg.c @@ -31,10 +31,12 @@ #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 ); @@ -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; } diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 8d989bc6f6..fa9ecfbd4f 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -75,6 +75,7 @@
#include "wine/unicode.h" #include "wine/debug.h" +#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
@@ -236,10 +237,6 @@ 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); @@ -349,7 +346,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; @@ -379,7 +376,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); }
@@ -388,7 +385,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); } } @@ -410,7 +407,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; } @@ -426,7 +423,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); }
@@ -442,7 +439,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); }
@@ -453,8 +450,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); }
/*********************************************************************** @@ -470,7 +467,7 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type) /* 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); }
@@ -490,19 +487,19 @@ 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); return ret; }
@@ -580,7 +577,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 */ @@ -908,7 +905,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) { @@ -928,7 +925,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; }
@@ -1589,8 +1586,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", @@ -1624,8 +1621,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)); @@ -1633,7 +1630,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"); } @@ -1659,8 +1656,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; @@ -1672,7 +1669,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); @@ -1680,7 +1677,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; } } @@ -1712,8 +1709,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; @@ -1727,7 +1724,7 @@ 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)) { @@ -1744,7 +1741,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) } 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)); @@ -2264,7 +2261,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); @@ -2275,12 +2272,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 */ @@ -2517,7 +2514,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 @@ -2564,9 +2561,9 @@ 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 */ @@ -2641,7 +2638,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 @@ -2663,7 +2660,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) } else { - HeapFree(GetProcessHeap(), 0, filterExt); + heap_free(filterExt); filterExt = NULL; } } @@ -2671,7 +2668,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); }
@@ -2683,7 +2680,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)) @@ -2996,7 +2993,7 @@ 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 */ @@ -3027,7 +3024,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) 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;
@@ -3076,7 +3073,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 @@ -3108,7 +3105,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode) (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); @@ -3117,7 +3114,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); @@ -3170,13 +3167,12 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd) { for(iPos = iCount-1;iPos>=0;iPos--) { - MemFree((LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos)); + heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos)); CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos); } } /* Current filter */ - MemFree(fodInfos->ShellInfos.lpstrCurrentFilter); - + heap_free(fodInfos->ShellInfos.lpstrCurrentFilter); }
/*********************************************************************** @@ -3212,7 +3208,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);
@@ -3441,7 +3437,7 @@ 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*/ @@ -3487,7 +3483,7 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId) }
COMDLG32_SHFree( tmpFolder->pidlItem ); - MemFree( tmpFolder ); + heap_free( tmpFolder ); return -1;
} @@ -3584,7 +3580,7 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd) { SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos); COMDLG32_SHFree(tmpFolder->pidlItem); - MemFree(tmpFolder); + heap_free(tmpFolder); CBDeleteString(hwnd,iItemPos); liInfos->iMaxIndentation--;
@@ -3644,13 +3640,13 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd) { SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos); COMDLG32_SHFree(tmpFolder->pidlItem); - MemFree(tmpFolder); + heap_free(tmpFolder); CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos); } }
/* LookInInfos structure */ - MemFree(liInfos); + heap_free(liInfos); RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr); }
@@ -3698,7 +3694,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;
@@ -3745,7 +3741,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) }
ret: - HeapFree(GetProcessHeap(), 0, lpstrAllFiles); + heap_free(lpstrAllFiles); COMCTL32_ReleaseStgMedium(medium); }
@@ -3797,13 +3793,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; }
@@ -4052,18 +4048,6 @@ static BOOL BrowseSelectedFolder(HWND hwnd) 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) || @@ -4220,11 +4204,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; }
diff --git a/dlls/comdlg32/filedlg31.c b/dlls/comdlg32/filedlg31.c index 0409915737..de04e85998 100644 --- a/dlls/comdlg32/filedlg31.c +++ b/dlls/comdlg32/filedlg31.c @@ -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" @@ -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) { @@ -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; @@ -786,7 +787,7 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS, buf, sizeof(buf)/sizeof(WCHAR)); 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 +820,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 +845,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 +919,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 +941,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); } diff --git a/dlls/comdlg32/finddlg.c b/dlls/comdlg32/finddlg.c index bc4a31c605..d769325e9f 100644 --- a/dlls/comdlg32/finddlg.c +++ b/dlls/comdlg32/finddlg.c @@ -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; } diff --git a/dlls/comdlg32/fontdlg.c b/dlls/comdlg32/fontdlg.c index 768ca4a6ea..0c9b4b1c9d 100644 --- a/dlls/comdlg32/fontdlg.c +++ b/dlls/comdlg32/fontdlg.c @@ -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" @@ -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); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
Fixes https://bugs.winehq.org/show_bug.cgi?id=38829
dlls/comdlg32/filedlg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index fa9ecfbd4f..81eaecafc3 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -1331,9 +1331,13 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETIMAGELIST, 0, 0); ImageList_Destroy(himl); } - RemovePropW(hwnd, filedlg_info_propnameW); return FALSE; } + + case WM_NCDESTROY: + RemovePropW(hwnd, filedlg_info_propnameW); + return 0; + case WM_NOTIFY: { LPNMHDR lpnmh = (LPNMHDR)lParam;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comdlg32/cdlg.h | 2 ++ dlls/comdlg32/colordlg.c | 2 +- dlls/comdlg32/filedlg31.c | 11 +++++------ dlls/comdlg32/filedlgbrowser.c | 4 ++-- dlls/comdlg32/fontdlg.c | 20 ++++++++++---------- dlls/comdlg32/itemdlg.c | 6 +++--- dlls/comdlg32/printdlg.c | 26 +++++++++++++------------- 7 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index 849b9863e0..be0a298e13 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -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 */
diff --git a/dlls/comdlg32/colordlg.c b/dlls/comdlg32/colordlg.c index a717e847c7..1e8c26bf32 100644 --- a/dlls/comdlg32/colordlg.c +++ b/dlls/comdlg32/colordlg.c @@ -402,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;
diff --git a/dlls/comdlg32/filedlg31.c b/dlls/comdlg32/filedlg31.c index de04e85998..76ac503014 100644 --- a/dlls/comdlg32/filedlg31.c +++ b/dlls/comdlg32/filedlg31.c @@ -106,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); @@ -532,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)) { @@ -563,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 */ @@ -784,8 +784,7 @@ 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 = heap_alloc(len * sizeof(WCHAR)); memcpy(title_tmp, buf, len * sizeof(WCHAR)); diff --git a/dlls/comdlg32/filedlgbrowser.c b/dlls/comdlg32/filedlgbrowser.c index a225e9e590..baa9f1a790 100644 --- a/dlls/comdlg32/filedlgbrowser.c +++ b/dlls/comdlg32/filedlgbrowser.c @@ -116,7 +116,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"); @@ -847,7 +847,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); } } diff --git a/dlls/comdlg32/fontdlg.c b/dlls/comdlg32/fontdlg.c index 0c9b4b1c9d..9f9f48aeea 100644 --- a/dlls/comdlg32/fontdlg.c +++ b/dlls/comdlg32/fontdlg.c @@ -163,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"); @@ -443,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; } @@ -664,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)); } @@ -904,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;
@@ -935,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) { @@ -1017,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, @@ -1029,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); @@ -1099,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; } @@ -1113,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); } diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 8aaaa2103e..c8eff3438d 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -657,7 +657,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);
@@ -2508,7 +2508,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); }
@@ -4623,7 +4623,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); } diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index 83335a9503..429903b84d 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -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);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comdlg32/filedlg.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 81eaecafc3..e721c081dd 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -84,8 +84,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 */ @@ -184,6 +182,11 @@ 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; +} + /*********************************************************************** * Prototypes */ @@ -307,7 +310,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); @@ -824,15 +827,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 { @@ -2014,7 +2017,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;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comdlg32/filedlg.c | 85 ++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 54 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index e721c081dd..a882f80417 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -131,40 +131,9 @@ typedef struct tagLookInInfo */
/* 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 */
@@ -2575,7 +2544,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
/* 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 */ @@ -3004,8 +2973,9 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) 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) @@ -3026,7 +2996,7 @@ 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++;
@@ -3036,7 +3006,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) 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; @@ -3066,7 +3036,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, @@ -3105,7 +3075,7 @@ 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 + @@ -3141,7 +3111,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));
@@ -3165,7 +3137,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");
@@ -3175,7 +3149,7 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd) for(iPos = iCount-1;iPos>=0;iPos--) { heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos)); - CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos); + SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_DELETESTRING, iPos, 0); } } /* Current filter */ @@ -3229,11 +3203,11 @@ 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); @@ -3399,7 +3373,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;
@@ -3477,15 +3451,15 @@ 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; }
@@ -3561,7 +3535,7 @@ int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl) } }
- CBSetCurSel(hwnd,iItemPos); + SendMessageW(hwnd, CB_SETCURSEL, iItemPos, 0); liInfos->uSelectedItem = iItemPos;
return 0; @@ -3588,7 +3562,7 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd) SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos); COMDLG32_SHFree(tmpFolder->pidlItem); heap_free(tmpFolder); - CBDeleteString(hwnd,iItemPos); + SendMessageW(hwnd, CB_DELETESTRING, iItemPos, 0); liInfos->iMaxIndentation--;
return iItemPos; @@ -3606,7 +3580,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);
@@ -3635,8 +3611,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");
@@ -3648,7 +3625,7 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd) SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos); COMDLG32_SHFree(tmpFolder->pidlItem); heap_free(tmpFolder); - CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos); + SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_DELETESTRING, iPos, 0); } }