[COMDLG32] Sync with Wine Staging 3.9. CORE-14656

This commit is contained in:
Amine Khaldi 2018-05-27 04:06:36 +01:00
parent 41e2b83f96
commit f68b0c5100
13 changed files with 528 additions and 389 deletions

View 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

View 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;
}

View file

@ -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 );
@ -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;
}

File diff suppressed because it is too large Load diff

View 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);
}

View 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);
}
}

View 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

View 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;
}

View 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);
}

View 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);
}

View file

@ -32,6 +32,7 @@
#define NO_SHLWAPI_STREAM
#include <shlwapi.h>
#include <wine/heap.h>
#include <wine/unicode.h>
#include <wine/debug.h>

View 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);

View 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