ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
May 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
23 participants
218 discussions
Start a n
N
ew thread
01/01: [COMDLG32] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f68b0c5100fde385c9cfa…
commit f68b0c5100fde385c9cfa19b21af8ba614488c29 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:06:36 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:06:36 2018 +0100 [COMDLG32] Sync with Wine Staging 3.9. CORE-14656 --- dll/win32/comdlg32/cdlg.h | 14 +- dll/win32/comdlg32/cdlg32.c | 54 +--- dll/win32/comdlg32/colordlg.c | 19 +- dll/win32/comdlg32/filedlg.c | 615 +++++++++++++++++++++++------------- dll/win32/comdlg32/filedlg31.c | 66 ++-- dll/win32/comdlg32/filedlgbrowser.c | 74 +++-- dll/win32/comdlg32/filedlgbrowser.h | 2 + dll/win32/comdlg32/finddlg.c | 5 +- dll/win32/comdlg32/fontdlg.c | 33 +- dll/win32/comdlg32/itemdlg.c | 6 +- dll/win32/comdlg32/precomp.h | 1 + dll/win32/comdlg32/printdlg.c | 26 +- media/doc/README.WINE | 2 +- 13 files changed, 528 insertions(+), 389 deletions(-) diff --git a/dll/win32/comdlg32/cdlg.h b/dll/win32/comdlg32/cdlg.h index 849b9863e0..eebf1a9b2b 100644 --- a/dll/win32/comdlg32/cdlg.h +++ b/dll/win32/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 */ @@ -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 diff --git a/dll/win32/comdlg32/cdlg32.c b/dll/win32/comdlg32/cdlg32.c index daf03f0af4..1c21025cfd 100644 --- a/dll/win32/comdlg32/cdlg32.c +++ b/dll/win32/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); @@ -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; } diff --git a/dll/win32/comdlg32/colordlg.c b/dll/win32/comdlg32/colordlg.c index bead9ba38c..1e8c26bf32 100644 --- a/dll/win32/comdlg32/colordlg.c +++ b/dll/win32/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 ); @@ -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; } diff --git a/dll/win32/comdlg32/filedlg.c b/dll/win32/comdlg32/filedlg.c index 41b796684c..cd856471f8 100644 --- a/dll/win32/comdlg32/filedlg.c +++ b/dll/win32/comdlg32/filedlg.c @@ -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; } diff --git a/dll/win32/comdlg32/filedlg31.c b/dll/win32/comdlg32/filedlg31.c index 0409915737..76ac503014 100644 --- a/dll/win32/comdlg32/filedlg31.c +++ b/dll/win32/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" @@ -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); } diff --git a/dll/win32/comdlg32/filedlgbrowser.c b/dll/win32/comdlg32/filedlgbrowser.c index a225e9e590..5b5323f4d2 100644 --- a/dll/win32/comdlg32/filedlgbrowser.c +++ b/dll/win32/comdlg32/filedlgbrowser.c @@ -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); } } diff --git a/dll/win32/comdlg32/filedlgbrowser.h b/dll/win32/comdlg32/filedlgbrowser.h index 5cb5435b89..21eb3d56df 100644 --- a/dll/win32/comdlg32/filedlgbrowser.h +++ b/dll/win32/comdlg32/filedlgbrowser.h @@ -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 diff --git a/dll/win32/comdlg32/finddlg.c b/dll/win32/comdlg32/finddlg.c index bc4a31c605..d769325e9f 100644 --- a/dll/win32/comdlg32/finddlg.c +++ b/dll/win32/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/dll/win32/comdlg32/fontdlg.c b/dll/win32/comdlg32/fontdlg.c index 768ca4a6ea..9f9f48aeea 100644 --- a/dll/win32/comdlg32/fontdlg.c +++ b/dll/win32/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" @@ -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); } diff --git a/dll/win32/comdlg32/itemdlg.c b/dll/win32/comdlg32/itemdlg.c index 2b7a6fe6e9..f1f0492353 100644 --- a/dll/win32/comdlg32/itemdlg.c +++ b/dll/win32/comdlg32/itemdlg.c @@ -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); } diff --git a/dll/win32/comdlg32/precomp.h b/dll/win32/comdlg32/precomp.h index 0f5a9349d9..c108058ff1 100644 --- a/dll/win32/comdlg32/precomp.h +++ b/dll/win32/comdlg32/precomp.h @@ -32,6 +32,7 @@ #define NO_SHLWAPI_STREAM #include <shlwapi.h> +#include <wine/heap.h> #include <wine/unicode.h> #include <wine/debug.h> diff --git a/dll/win32/comdlg32/printdlg.c b/dll/win32/comdlg32/printdlg.c index 83335a9503..429903b84d 100644 --- a/dll/win32/comdlg32/printdlg.c +++ b/dll/win32/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); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 65532ccdb5..44573b5156 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -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
6 years, 7 months
1
0
0
0
01/01: [INCLUDE/WINE][USER32_APITEST] Add ARRAY_SIZE to test.h and remove it from RealGetWindowClass.c. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=41e2b83f9655acf292660…
commit 41e2b83f9655acf292660f9ae6898fc34d9f98d8 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:05:33 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:05:33 2018 +0100 [INCLUDE/WINE][USER32_APITEST] Add ARRAY_SIZE to test.h and remove it from RealGetWindowClass.c. CORE-14656 --- modules/rostests/apitests/user32/RealGetWindowClass.c | 2 -- sdk/include/reactos/wine/test.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/rostests/apitests/user32/RealGetWindowClass.c b/modules/rostests/apitests/user32/RealGetWindowClass.c index 856c28c71f..e5274d5cc3 100644 --- a/modules/rostests/apitests/user32/RealGetWindowClass.c +++ b/modules/rostests/apitests/user32/RealGetWindowClass.c @@ -7,8 +7,6 @@ #include "precomp.h" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) - static PWSTR ControlsList[] = { L"Button\0", diff --git a/sdk/include/reactos/wine/test.h b/sdk/include/reactos/wine/test.h index 25c4ff5681..0b4c54019c 100644 --- a/sdk/include/reactos/wine/test.h +++ b/sdk/include/reactos/wine/test.h @@ -155,6 +155,7 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ); #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine")) #endif +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #ifdef NONAMELESSUNION # define U(x) (x).u
6 years, 7 months
1
0
0
0
01/01: [PSDK] Add missing OFN_EX_NOPLACESBAR. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2f668a30bd967437ff105…
commit 2f668a30bd967437ff105d3e0d7fc4bb0a6a0888 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:03:38 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:03:38 2018 +0100 [PSDK] Add missing OFN_EX_NOPLACESBAR. CORE-14656 --- sdk/include/psdk/commdlg.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/include/psdk/commdlg.h b/sdk/include/psdk/commdlg.h index 6d2df200b9..4680cca8c1 100644 --- a/sdk/include/psdk/commdlg.h +++ b/sdk/include/psdk/commdlg.h @@ -118,6 +118,7 @@ extern "C" { #define OFN_READONLY 1 #define OFN_SHAREAWARE 0x4000 #define OFN_SHOWHELP 16 +#define OFN_EX_NOPLACESBAR 0x00000001 #define OFN_SHAREFALLTHROUGH 2 #define OFN_SHARENOWARN 1 #define OFN_SHAREWARN 0
6 years, 7 months
1
0
0
0
01/01: [AVIFIL32] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=01707e98b592fb3ca9964…
commit 01707e98b592fb3ca9964ed4f2fcc1161ecfe4c8 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:02:26 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:02:26 2018 +0100 [AVIFIL32] Sync with Wine Staging 3.9. CORE-14656 --- dll/win32/avifil32/api.c | 12 +++--- dll/win32/avifil32/avifil32.idl | 83 +++++++++++++++++++++++++++++++++--- dll/win32/avifil32/avifil32_idl.rgs | 20 ++++++--- dll/win32/avifil32/avifile.c | 8 ++-- dll/win32/avifil32/avifile_private.h | 2 + dll/win32/avifil32/wavfile.c | 4 +- media/doc/README.WINE | 2 +- 7 files changed, 108 insertions(+), 23 deletions(-) diff --git a/dll/win32/avifil32/api.c b/dll/win32/avifil32/api.c index 5c15c1fe83..63a3530591 100644 --- a/dll/win32/avifil32/api.c +++ b/dll/win32/avifil32/api.c @@ -156,7 +156,7 @@ static BOOL AVIFILE_GetFileHandlerByExtension(LPCWSTR szFile, LPCLSID lpclsid) CHAR szRegKey[25]; CHAR szValue[100]; LPWSTR szExt = strrchrW(szFile, '.'); - LONG len = sizeof(szValue) / sizeof(szValue[0]); + LONG len = ARRAY_SIZE(szValue); if (szExt == NULL) return FALSE; @@ -371,7 +371,7 @@ HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile, PAVISTREAM *ppavi, /* Only the szName at the end is different */ memcpy(&psiw, psi, sizeof(*psi) - sizeof(psi->szName)); MultiByteToWideChar(CP_ACP, 0, psi->szName, -1, psiw.szName, - sizeof(psiw.szName) / sizeof(psiw.szName[0])); + ARRAY_SIZE(psiw.szName)); return IAVIFile_CreateStream(pfile, ppavi, &psiw); } @@ -1035,7 +1035,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) HeapFree(GetProcessHeap(), 0, lp); return AVIERR_ERROR; } - for (n = 0;RegEnumKeyW(hKey, n, szFileExt, sizeof(szFileExt)/sizeof(szFileExt[0])) == ERROR_SUCCESS;n++) { + for (n = 0;RegEnumKeyW(hKey, n, szFileExt, ARRAY_SIZE(szFileExt)) == ERROR_SUCCESS;n++) { WCHAR clsidW[40]; /* get CLSID to extension */ @@ -1300,7 +1300,7 @@ static void AVISaveOptionsUpdate(HWND hWnd) } else { LoadStringW(AVIFILE_hModule, IDS_UNCOMPRESSED, icinfo.szDescription, - sizeof(icinfo.szDescription)/sizeof(icinfo.szDescription[0])); + ARRAY_SIZE(icinfo.szDescription)); lstrcatW(szFormat, icinfo.szDescription); } } else if (sInfo.fccType == streamtypeAUDIO) { @@ -2160,7 +2160,7 @@ HRESULT WINAPI EditStreamSetNameA(PAVISTREAM pstream, LPCSTR szName) return hres; memset(asia.szName, 0, sizeof(asia.szName)); - lstrcpynA(asia.szName, szName, sizeof(asia.szName)/sizeof(asia.szName[0])); + lstrcpynA(asia.szName, szName, ARRAY_SIZE(asia.szName)); return EditStreamSetInfoA(pstream, &asia, sizeof(asia)); } @@ -2185,7 +2185,7 @@ HRESULT WINAPI EditStreamSetNameW(PAVISTREAM pstream, LPCWSTR szName) return hres; memset(asiw.szName, 0, sizeof(asiw.szName)); - lstrcpynW(asiw.szName, szName, sizeof(asiw.szName)/sizeof(asiw.szName[0])); + lstrcpynW(asiw.szName, szName, ARRAY_SIZE(asiw.szName)); return EditStreamSetInfoW(pstream, &asiw, sizeof(asiw)); } diff --git a/dll/win32/avifil32/avifil32.idl b/dll/win32/avifil32/avifil32.idl index e23c176051..1e3f191622 100644 --- a/dll/win32/avifil32/avifil32.idl +++ b/dll/win32/avifil32/avifil32.idl @@ -21,14 +21,80 @@ #pragma makedep proxy #pragma makedep register -#include "avifile_ifaces.idl" +import "wtypes.idl"; +import "unknwn.idl"; + +typedef struct _AVISTREAMINFOW +{ + DWORD fccType; + DWORD fccHandler; + DWORD dwFlags; + DWORD dwCaps; + WORD wPriority; + WORD wLanguage; + DWORD dwScale; + DWORD dwRate; + DWORD dwStart; + DWORD dwLength; + DWORD dwInitialFrames; + DWORD dwSuggestedBufferSize; + DWORD dwQuality; + DWORD dwSampleSize; + RECT rcFrame; + DWORD dwEditCount; + DWORD dwFormatChangeCount; + WCHAR szName[64]; +} AVISTREAMINFOW; [ - helpstring("IAVIStream & IAVIFile Proxy"), - threading(both), - uuid(0002000d-0000-0000-c000-000000000046) + object, + uuid(00020021-0000-0000-c000-000000000046) ] -coclass PSFactoryBuffer { interface IFactoryBuffer; } +interface IAVIStream : IUnknown +{ + HRESULT Create(LPARAM lParam1, LPARAM lParam2); + HRESULT Info(AVISTREAMINFOW *psi, LONG lSize); + LONG FindSample(LONG lPos, LONG lFlags); + HRESULT ReadFormat(LONG lPos, [out,size_is(*lpcbFormat)] char *lpFormat, [in,out] LONG *lpcbFormat); + HRESULT SetFormat(LONG lPos, [in,size_is(cbFormat)] char *lpFormat, LONG cbFormat); + HRESULT Read(LONG lStart, LONG lSamples, [out,size_is(cbBuffer)] char *lpBuffer, LONG cbBuffer, LONG *plBytes, LONG *plSamples); + HRESULT Write(LONG lStart, LONG lSamples, [in,size_is(cbBuffer)] char *lpBuffer, LONG cbBuffer, DWORD dwFlags, LONG *plSampWritten, LONG *plBytesWritten); + HRESULT Delete(LONG lStart, LONG lSamples); + HRESULT ReadData(DWORD fcc, [out,size_is(*lpcbBuffer)] char *lpBuffer, [in,out] LONG *lpcbBuffer); + HRESULT WriteData(DWORD fcc, [in,size_is(cbBuffer)] char *lpBuffer, LONG cbBuffer); + HRESULT SetInfo(AVISTREAMINFOW *plInfo, LONG cbInfo); +}; + +typedef struct _AVIFILEINFOW +{ + DWORD dwMaxBytesPerSec; + DWORD dwFlags; + DWORD dwCaps; + DWORD dwStreams; + DWORD dwSuggestedBufferSize; + DWORD dwWidth; + DWORD dwHeight; + DWORD dwScale; + DWORD dwRate; + DWORD dwLength; + DWORD dwEditCount; + WCHAR szFileType[64]; +} AVIFILEINFOW; + +[ + object, + uuid(00020020-0000-0000-c000-000000000046) +] +interface IAVIFile : IUnknown +{ + HRESULT Info(AVIFILEINFOW *pfi, LONG lSize); + HRESULT GetStream(IAVIStream **ppStream, DWORD fccType, LONG lParam); + HRESULT CreateStream(IAVIStream **ppStream, AVISTREAMINFOW *psi); + HRESULT WriteData(DWORD fcc, [in,size_is(cbBuffer)] char *lpBuffer, LONG cbBuffer); + HRESULT ReadData(DWORD fcc, [out,size_is(*lpcbBuffer)] char *lpBuffer, [in,out] LONG *lpcbBuffer); + HRESULT EndRecord(void); + HRESULT DeleteStream(DWORD fccType, LONG lParam); +}; [ helpstring("Microsoft AVI Files"), @@ -51,6 +117,13 @@ coclass ICMStream { interface IAVIStream; } ] coclass WAVFile { interface IAVIFile; } +[ + helpstring("IAVIStream & IAVIFile Proxy"), + threading(both), + uuid(0002000d-0000-0000-c000-000000000046) +] +coclass PSFactoryBuffer { interface IFactoryBuffer; } + [ helpstring("ACM Compressed Audio Stream"), threading(both), diff --git a/dll/win32/avifil32/avifil32_idl.rgs b/dll/win32/avifil32/avifil32_idl.rgs index 07c0706d28..9faf6f7638 100644 --- a/dll/win32/avifil32/avifil32_idl.rgs +++ b/dll/win32/avifil32/avifil32_idl.rgs @@ -2,28 +2,38 @@ HKCR { NoRemove Interface { + '{00020021-0000-0000-C000-000000000046}' = s 'IAVIStream' + { + NumMethods = s 14 + ProxyStubClsid32 = s '{0002000D-0000-0000-C000-000000000046}' + } + '{00020020-0000-0000-C000-000000000046}' = s 'IAVIFile' + { + NumMethods = s 10 + ProxyStubClsid32 = s '{0002000D-0000-0000-C000-000000000046}' + } } NoRemove CLSID { '{00020000-0000-0000-C000-000000000046}' = s 'Microsoft AVI Files' { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } '{00020001-0000-0000-C000-000000000046}' = s 'AVI Compressed Stream' { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } '{00020003-0000-0000-C000-000000000046}' = s 'Microsoft Wave File' { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } '{0002000D-0000-0000-C000-000000000046}' = s 'IAVIStream & IAVIFile Proxy' { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } '{0002000F-0000-0000-C000-000000000046}' = s 'ACM Compressed Audio Stream' { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } } } diff --git a/dll/win32/avifil32/avifile.c b/dll/win32/avifil32/avifile.c index 7a4caaadb4..33c28b145d 100644 --- a/dll/win32/avifil32/avifile.c +++ b/dll/win32/avifil32/avifile.c @@ -1641,7 +1641,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) This->fInfo.dwWidth = MainAVIHdr.dwWidth; This->fInfo.dwHeight = MainAVIHdr.dwHeight; LoadStringW(AVIFILE_hModule, IDS_AVIFILETYPE, This->fInfo.szFileType, - sizeof(This->fInfo.szFileType)/sizeof(This->fInfo.szFileType[0])); + ARRAY_SIZE(This->fInfo.szFileType)); /* go back to into header list */ if (mmioAscend(This->hmmio, &ck, 0) != S_OK) @@ -1751,9 +1751,9 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) /* generate description for stream like "filename.avi Type #n" */ if (streamHdr.fccType == streamtypeVIDEO) - LoadStringW(AVIFILE_hModule, IDS_VIDEO, szType, sizeof(szType)/sizeof(szType[0])); + LoadStringW(AVIFILE_hModule, IDS_VIDEO, szType, ARRAY_SIZE(szType)); else if (streamHdr.fccType == streamtypeAUDIO) - LoadStringW(AVIFILE_hModule, IDS_AUDIO, szType, sizeof(szType)/sizeof(szType[0])); + LoadStringW(AVIFILE_hModule, IDS_AUDIO, szType, ARRAY_SIZE(szType)); else wsprintfW(szType, streamTypeFmt, (char*)&streamHdr.fccType); @@ -1784,7 +1784,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) } MultiByteToWideChar(CP_ACP, 0, str, -1, pStream->sInfo.szName, - sizeof(pStream->sInfo.szName)/sizeof(pStream->sInfo.szName[0])); + ARRAY_SIZE(pStream->sInfo.szName)); HeapFree(GetProcessHeap(), 0, str); } diff --git a/dll/win32/avifil32/avifile_private.h b/dll/win32/avifil32/avifile_private.h index 4bf11f42a8..83e87ea989 100644 --- a/dll/win32/avifil32/avifile_private.h +++ b/dll/win32/avifil32/avifile_private.h @@ -22,6 +22,8 @@ #include <windef.h> #include <winuser.h> +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + #ifndef MAX_AVISTREAMS #define MAX_AVISTREAMS 8 #endif diff --git a/dll/win32/avifil32/wavfile.c b/dll/win32/avifil32/wavfile.c index d2d203b4b9..6294ecdc39 100644 --- a/dll/win32/avifil32/wavfile.c +++ b/dll/win32/avifil32/wavfile.c @@ -522,9 +522,9 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile memset(& This->sInfo, 0, sizeof(This->sInfo)); LoadStringW(AVIFILE_hModule, IDS_WAVEFILETYPE, This->fInfo.szFileType, - sizeof(This->fInfo.szFileType)/sizeof(This->fInfo.szFileType[0])); + ARRAY_SIZE(This->fInfo.szFileType)); if (LoadStringW(AVIFILE_hModule, IDS_WAVESTREAMFORMAT, - wszStreamFmt, sizeof(wszStreamFmt)/sizeof(wszStreamFmt[0])) > 0) { + wszStreamFmt, ARRAY_SIZE(wszStreamFmt)) > 0) { wsprintfW(This->sInfo.szName, wszStreamFmt, AVIFILE_BasenameW(This->szFileName)); } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 5da4269676..65532ccdb5 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -48,7 +48,7 @@ reactos/dll/win32/advpack # Synced to WineStaging-3.3 reactos/dll/win32/atl # Synced to WineStaging-3.3 reactos/dll/win32/atl80 # Synced to WineStaging-3.3 reactos/dll/win32/atl100 # Synced to WineStaging-3.3 -reactos/dll/win32/avifil32 # Synced to WineStaging-3.3 +reactos/dll/win32/avifil32 # Synced to WineStaging-3.9 reactos/dll/win32/bcrypt # Synced to WineStaging-1.9.23 reactos/dll/win32/browseui # Out of sync reactos/dll/win32/cabinet # Synced to WineStaging-3.3
6 years, 7 months
1
0
0
0
01/01: [QUARTZ_WINETEST] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=202ccf50ba76708e32927…
commit 202ccf50ba76708e32927db3199d2088e6ccf3c4 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:01:18 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:01:18 2018 +0100 [QUARTZ_WINETEST] Sync with Wine Staging 3.9. CORE-14656 --- modules/rostests/winetests/quartz/filtermapper.c | 214 +++++++++++------------ 1 file changed, 102 insertions(+), 112 deletions(-) diff --git a/modules/rostests/winetests/quartz/filtermapper.c b/modules/rostests/winetests/quartz/filtermapper.c index cc28f6fc37..613d98d60f 100644 --- a/modules/rostests/winetests/quartz/filtermapper.c +++ b/modules/rostests/winetests/quartz/filtermapper.c @@ -48,24 +48,12 @@ static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum) hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat); ok(SUCCEEDED(hr), "IMoniker_BindToStorage failed with %x\n", hr); - if (FAILED(hr) || !pPropBagCat) - { - VariantClear(&var); - IMoniker_Release(pMoniker); - continue; - } hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, &var, NULL); ok(SUCCEEDED(hr), "IPropertyBag_Read failed with %x\n", hr); - if (SUCCEEDED(hr)) - { - CHAR val1[512], val2[512]; - - WideCharToMultiByte(CP_ACP, 0, V_BSTR(&var), -1, val1, sizeof(val1), 0, 0); - WideCharToMultiByte(CP_ACP, 0, wszFilterName, -1, val2, sizeof(val2), 0, 0); - if (!lstrcmpA(val1, val2)) found = TRUE; - } + if (!lstrcmpW(V_BSTR(&var), wszFilterName)) + found = TRUE; IPropertyBag_Release(pPropBagCat); IMoniker_Release(pMoniker); @@ -77,7 +65,9 @@ static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum) static void test_fm2_enummatchingfilters(void) { + IEnumRegFilters *enum_reg; IFilterMapper2 *pMapper = NULL; + IFilterMapper *mapper; HRESULT hr; REGFILTER2 rgf2; REGFILTERPINS2 rgPins2[2]; @@ -88,6 +78,8 @@ static void test_fm2_enummatchingfilters(void) CLSID clsidFilter2; IEnumMoniker *pEnum = NULL; BOOL found, registered = TRUE; + REGFILTER *regfilter; + ULONG count; ZeroMemory(&rgf2, sizeof(rgf2)); @@ -180,6 +172,21 @@ static void test_fm2_enummatchingfilters(void) found = enum_find_filter(wszFilterName1, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 1\n"); } + + hr = IFilterMapper2_QueryInterface(pMapper, &IID_IFilterMapper, (void **)&mapper); + ok(hr == S_OK, "QueryInterface(IFilterMapper) failed: %#x\n", hr); + + found = FALSE; + hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, + FALSE, GUID_NULL, GUID_NULL, FALSE, FALSE, GUID_NULL, GUID_NULL); + ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed: %#x\n", hr); + while (!found && IEnumRegFilters_Next(enum_reg, 1, ®filter, &count) == S_OK) + { + if (!lstrcmpW(regfilter->Name, wszFilterName1) && IsEqualGUID(&clsidFilter1, ®filter->Clsid)) + found = TRUE; + } + IEnumRegFilters_Release(enum_reg); + ok(found, "IFilterMapper didn't find filter\n"); } if (pEnum) IEnumMoniker_Release(pEnum); @@ -214,125 +221,108 @@ static void test_fm2_enummatchingfilters(void) static void test_legacy_filter_registration(void) { - IFilterMapper2 *pMapper2 = NULL; - IFilterMapper *pMapper = NULL; + static const WCHAR testfilterW[] = {'T','e','s','t','f','i','l','t','e','r',0}; + static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0}; + static const WCHAR pinW[] = {'P','i','n','1',0}; + IEnumRegFilters *enum_reg; + IEnumMoniker *enum_mon; + IFilterMapper2 *mapper2; + IFilterMapper *mapper; + REGFILTER *regfilter; + WCHAR clsidstring[40]; + WCHAR key_name[50]; + ULONG count; + CLSID clsid; + LRESULT ret; HRESULT hr; - static const WCHAR wszFilterName[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', 0 }; - static const CHAR szFilterName[] = "Testfilter"; - static const WCHAR wszPinName[] = {'P', 'i', 'n', '1', 0 }; - CLSID clsidFilter; - CHAR szRegKey[MAX_PATH]; - static const CHAR szClsid[] = "CLSID"; - WCHAR wszGuidstring[MAX_PATH]; - CHAR szGuidstring[MAX_PATH]; - LONG lRet; - HKEY hKey = NULL; - IEnumMoniker *pEnum = NULL; BOOL found; - IEnumRegFilters *pRegEnum = NULL; + HKEY hkey; + + /* Register* functions need a filter class key to write pin and pin media + * type data to. Create a bogus class key for it. */ + CoCreateGuid(&clsid); + StringFromGUID2(&clsid, clsidstring, sizeof(clsidstring)); + lstrcpyW(key_name, clsidW); + lstrcatW(key_name, clsidstring); + ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, key_name, 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL); + if (ret == ERROR_ACCESS_DENIED) + { + skip("Not authorized to register filters\n"); + return; + } /* Test if legacy filter registration scheme works (filter is added to HKCR\Filter). IFilterMapper_RegisterFilter * registers in this way. Filters so registered must then be accessible through both IFilterMapper_EnumMatchingFilters * and IFilterMapper2_EnumMatchingFilters. */ - hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, - &IID_IFilterMapper2, (LPVOID*)&pMapper2); + hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (void **)&mapper2); ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); - if (FAILED(hr)) goto out; - hr = IFilterMapper2_QueryInterface(pMapper2, &IID_IFilterMapper, (void **)&pMapper); + hr = IFilterMapper2_QueryInterface(mapper2, &IID_IFilterMapper, (void **)&mapper); ok(hr == S_OK, "IFilterMapper2_QueryInterface failed with %x\n", hr); - if (FAILED(hr)) goto out; - - /* Register a test filter. */ - hr = CoCreateGuid(&clsidFilter); - ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); - - lRet = StringFromGUID2(&clsidFilter, wszGuidstring, MAX_PATH); - ok(lRet > 0, "StringFromGUID2 failed\n"); - if (!lRet) goto out; - WideCharToMultiByte(CP_ACP, 0, wszGuidstring, -1, szGuidstring, MAX_PATH, 0, 0); - - lstrcpyA(szRegKey, szClsid); - lstrcatA(szRegKey, "\\"); - lstrcatA(szRegKey, szGuidstring); - - /* Register---- functions need a filter class key to write pin and pin media type data to. Create a bogus - * class key for it. */ - lRet = RegCreateKeyExA(HKEY_CLASSES_ROOT, szRegKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); - if (lRet == ERROR_ACCESS_DENIED) - skip("Not authorized to register filters\n"); - else - { - ok(lRet == ERROR_SUCCESS, "RegCreateKeyExA failed with %x\n", HRESULT_FROM_WIN32(lRet)); - /* Set default value - this is interpreted as "friendly name" later. */ - lRet = RegSetValueExA(hKey, NULL, 0, REG_SZ, (LPBYTE)szFilterName, lstrlenA(szFilterName) + 1); - ok(lRet == ERROR_SUCCESS, "RegSetValueExA failed with %x\n", HRESULT_FROM_WIN32(lRet)); + /* Set default value - this is interpreted as "friendly name" later. */ + RegSetValueExW(hkey, NULL, 0, REG_SZ, (BYTE *)testfilterW, sizeof(testfilterW)); + RegCloseKey(hkey); - if (hKey) RegCloseKey(hKey); - hKey = NULL; + hr = IFilterMapper_RegisterFilter(mapper, clsid, testfilterW, MERIT_UNLIKELY); + ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr); - hr = IFilterMapper_RegisterFilter(pMapper, clsidFilter, wszFilterName, MERIT_UNLIKELY); - ok(hr == S_OK, "IFilterMapper_RegisterFilter failed with %x\n", hr); + hr = IFilterMapper_RegisterPin(mapper, clsid, pinW, TRUE, FALSE, FALSE, FALSE, GUID_NULL, NULL); + ok(hr == S_OK, "RegisterPin failed: %#x\n", hr); - hr = IFilterMapper_RegisterPin(pMapper, clsidFilter, wszPinName, TRUE, FALSE, FALSE, FALSE, GUID_NULL, NULL); - ok(hr == S_OK, "IFilterMapper_RegisterPin failed with %x\n", hr); + hr = IFilterMapper_RegisterPinType(mapper, clsid, pinW, GUID_NULL, GUID_NULL); + ok(hr == S_OK, "RegisterPinType failed: %#x\n", hr); - hr = IFilterMapper_RegisterPinType(pMapper, clsidFilter, wszPinName, GUID_NULL, GUID_NULL); - ok(hr == S_OK, "IFilterMapper_RegisterPinType failed with %x\n", hr); + hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE, + 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); + ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed: %x\n", hr); + ok(enum_find_filter(testfilterW, enum_mon), "IFilterMapper2 didn't find filter\n"); + IEnumMoniker_Release(enum_mon); - hr = IFilterMapper2_EnumMatchingFilters(pMapper2, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, - 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); - ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); - if (SUCCEEDED(hr) && pEnum) - { - found = enum_find_filter(wszFilterName, pEnum); - ok(found, "IFilterMapper2_EnumMatchingFilters failed to return the test filter\n"); - } - - if (pEnum) IEnumMoniker_Release(pEnum); - pEnum = NULL; - - found = FALSE; - hr = IFilterMapper_EnumMatchingFilters(pMapper, &pRegEnum, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL, - FALSE, FALSE, GUID_NULL, GUID_NULL); - ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed with %x\n", hr); - if (SUCCEEDED(hr) && pRegEnum) - { - ULONG cFetched; - REGFILTER *prgf; - - while(!found && IEnumRegFilters_Next(pRegEnum, 1, &prgf, &cFetched) == S_OK) - { - CHAR val[512]; - - WideCharToMultiByte(CP_ACP, 0, prgf->Name, -1, val, sizeof(val), 0, 0); - if (!lstrcmpA(val, szFilterName)) found = TRUE; - - CoTaskMemFree(prgf); - } - - IEnumRegFilters_Release(pRegEnum); - } - ok(found, "IFilterMapper_EnumMatchingFilters failed to return the test filter\n"); - - hr = IFilterMapper_UnregisterFilter(pMapper, clsidFilter); - ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); + found = FALSE; + hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL, + FALSE, FALSE, GUID_NULL, GUID_NULL); + ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed with %x\n", hr); + while(!found && IEnumRegFilters_Next(enum_reg, 1, ®filter, &count) == S_OK) + { + if (!lstrcmpW(regfilter->Name, testfilterW) && IsEqualGUID(&clsid, ®filter->Clsid)) + found = TRUE; + } + IEnumRegFilters_Release(enum_reg); + ok(found, "IFilterMapper didn't find filter\n"); - lRet = RegOpenKeyExA(HKEY_CLASSES_ROOT, szClsid, 0, KEY_WRITE | DELETE, &hKey); - ok(lRet == ERROR_SUCCESS, "RegOpenKeyExA failed with %x\n", HRESULT_FROM_WIN32(lRet)); + hr = IFilterMapper_UnregisterFilter(mapper, clsid); + ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); - lRet = RegDeleteKeyA(hKey, szGuidstring); - ok(lRet == ERROR_SUCCESS, "RegDeleteKeyA failed with %x\n", HRESULT_FROM_WIN32(lRet)); + hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE, + 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); + ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed: %x\n", hr); + ok(!enum_find_filter(testfilterW, enum_mon), "IFilterMapper2 shouldn't find filter\n"); + IEnumMoniker_Release(enum_mon); + + found = FALSE; + hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL, + FALSE, FALSE, GUID_NULL, GUID_NULL); + ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed with %x\n", hr); + while(!found && IEnumRegFilters_Next(enum_reg, 1, ®filter, &count) == S_OK) + { + if (!lstrcmpW(regfilter->Name, testfilterW) && IsEqualGUID(&clsid, ®filter->Clsid)) + found = TRUE; } + IEnumRegFilters_Release(enum_reg); + ok(!found, "IFilterMapper shouldn't find filter\n"); - if (hKey) RegCloseKey(hKey); - hKey = NULL; + ret = RegDeleteKeyW(HKEY_CLASSES_ROOT, key_name); + ok(!ret, "RegDeleteKeyA failed: %lu\n", ret); - out: + hr = IFilterMapper_RegisterFilter(mapper, clsid, testfilterW, MERIT_UNLIKELY); + ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr); - if (pMapper) IFilterMapper_Release(pMapper); - if (pMapper2) IFilterMapper2_Release(pMapper2); + hr = IFilterMapper_UnregisterFilter(mapper, clsid); + ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); + + IFilterMapper_Release(mapper); + IFilterMapper2_Release(mapper2); } static ULONG getRefcount(IUnknown *iface)
6 years, 7 months
1
0
0
0
01/01: [QUARTZ] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f267af2ac1a960f6af1c3…
commit f267af2ac1a960f6af1c3e6d656ea3a1dadb2f26 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 04:00:39 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 04:00:39 2018 +0100 [QUARTZ] Sync with Wine Staging 3.9. CORE-14656 --- dll/directx/wine/quartz/dsoundrender.c | 8 ++++---- dll/directx/wine/quartz/filesource.c | 11 +++++------ dll/directx/wine/quartz/filtermapper.c | 7 +++++-- dll/directx/wine/quartz/parser.c | 10 +++++----- media/doc/README.WINE | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/dll/directx/wine/quartz/dsoundrender.c b/dll/directx/wine/quartz/dsoundrender.c index 7902955481..086352edba 100644 --- a/dll/directx/wine/quartz/dsoundrender.c +++ b/dll/directx/wine/quartz/dsoundrender.c @@ -491,7 +491,7 @@ static HRESULT WINAPI DSoundRender_CompleteConnect(BaseRenderer * iface, IPin * DSBCAPS_GETCURRENTPOSITION2; buf_desc.dwBufferBytes = This->buf_size; buf_desc.lpwfxFormat = format; - hr = IDirectSound_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL); + hr = IDirectSound8_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL); This->writepos = This->buf_size; if (FAILED(hr)) ERR("Can't create sound buffer (%x)\n", hr); @@ -645,14 +645,14 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv) if (FAILED(hr)) ERR("Cannot create Direct Sound object (%x)\n", hr); else - hr = IDirectSound_SetCooperativeLevel(pDSoundRender->dsound, GetDesktopWindow(), DSSCL_PRIORITY); + hr = IDirectSound8_SetCooperativeLevel(pDSoundRender->dsound, GetDesktopWindow(), DSSCL_PRIORITY); if (SUCCEEDED(hr)) { IDirectSoundBuffer *buf; DSBUFFERDESC buf_desc; memset(&buf_desc,0,sizeof(DSBUFFERDESC)); buf_desc.dwSize = sizeof(DSBUFFERDESC); buf_desc.dwFlags = DSBCAPS_PRIMARYBUFFER; - hr = IDirectSound_CreateSoundBuffer(pDSoundRender->dsound, &buf_desc, &buf, NULL); + hr = IDirectSound8_CreateSoundBuffer(pDSoundRender->dsound, &buf_desc, &buf, NULL); if (SUCCEEDED(hr)) { IDirectSoundBuffer_Play(buf, 0, 0, DSBPLAY_LOOPING); IDirectSoundBuffer_Release(buf); @@ -736,7 +736,7 @@ static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface) IDirectSoundBuffer_Release(This->dsbuffer); This->dsbuffer = NULL; if (This->dsound) - IDirectSound_Release(This->dsound); + IDirectSound8_Release(This->dsound); This->dsound = NULL; BasicAudio_Destroy(&This->basicAudio); diff --git a/dll/directx/wine/quartz/filesource.c b/dll/directx/wine/quartz/filesource.c index 4290ac351d..0413eb45ed 100644 --- a/dll/directx/wine/quartz/filesource.c +++ b/dll/directx/wine/quartz/filesource.c @@ -783,12 +783,11 @@ static inline FileAsyncReader *impl_from_IAsyncReader(IAsyncReader *iface) return CONTAINING_RECORD(iface, FileAsyncReader, IAsyncReader_iface); } -static HRESULT WINAPI FileAsyncReaderPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt) +static HRESULT WINAPI FileAsyncReaderPin_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *pmt) { - FileAsyncReader *This = impl_from_IPin(iface); - AM_MEDIA_TYPE *pmt_filter = impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter)->pmt; + AM_MEDIA_TYPE *pmt_filter = impl_from_IBaseFilter(pin->pinInfo.pFilter)->pmt; - FIXME("(%p, %p)\n", iface, pmt); + FIXME("(%p, %p)\n", pin, pmt); if (IsEqualGUID(&pmt->majortype, &pmt_filter->majortype) && IsEqualGUID(&pmt->subtype, &pmt_filter->subtype) && @@ -874,7 +873,7 @@ static const IPinVtbl FileAsyncReaderPin_Vtbl = BasePinImpl_QueryPinInfo, BasePinImpl_QueryDirection, BasePinImpl_QueryId, - FileAsyncReaderPin_QueryAccept, + BasePinImpl_QueryAccept, BasePinImpl_EnumMediaTypes, BasePinImpl_QueryInternalConnections, BaseOutputPinImpl_EndOfStream, @@ -933,7 +932,7 @@ static HRESULT WINAPI FileAsyncReaderPin_DecideBufferSize(BaseOutputPin *iface, static const BaseOutputPinFuncTable output_BaseOutputFuncTable = { { - NULL, + FileAsyncReaderPin_CheckMediaType, FileAsyncReaderPin_AttemptConnection, BasePinImpl_GetMediaTypeVersion, FileAsyncReaderPin_GetMediaType diff --git a/dll/directx/wine/quartz/filtermapper.c b/dll/directx/wine/quartz/filtermapper.c index 2dd316d877..358c40e096 100644 --- a/dll/directx/wine/quartz/filtermapper.c +++ b/dll/directx/wine/quartz/filtermapper.c @@ -1524,22 +1524,25 @@ static HRESULT WINAPI FilterMapper_UnregisterFilter(IFilterMapper * iface, CLSID strcatW(wszKeyName, wszClsid); lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, KEY_WRITE, &hKey); + if (lRet == ERROR_FILE_NOT_FOUND) + goto done; hr = HRESULT_FROM_WIN32(lRet); } if (SUCCEEDED(hr)) { lRet = RegDeleteValueW(hKey, wszMeritName); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) hr = HRESULT_FROM_WIN32(lRet); lRet = RegDeleteTreeW(hKey, wszPins); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) hr = HRESULT_FROM_WIN32(lRet); RegCloseKey(hKey); } +done: CoTaskMemFree(wszClsid); return hr; diff --git a/dll/directx/wine/quartz/parser.c b/dll/directx/wine/quartz/parser.c index 4b968a398c..7b550b0ff6 100644 --- a/dll/directx/wine/quartz/parser.c +++ b/dll/directx/wine/quartz/parser.c @@ -44,6 +44,7 @@ static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface); static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface); static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface); static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest); +static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *pmt); static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt); static HRESULT WINAPI Parser_OutputPin_DecideAllocator(BaseOutputPin *This, IMemInputPin *pPin, IMemAllocator **pAlloc); static HRESULT WINAPI Parser_OutputPin_BreakConnect(BaseOutputPin *This); @@ -432,7 +433,7 @@ HRESULT WINAPI Parser_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo) static const BaseOutputPinFuncTable output_BaseOutputFuncTable = { { - NULL, + Parser_OutputPin_CheckMediaType, BaseOutputPinImpl_AttemptConnection, BasePinImpl_GetMediaTypeVersion, Parser_OutputPin_GetMediaType @@ -699,11 +700,10 @@ static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, return BaseOutputPinImpl_Connect(iface, pReceivePin, pmt); } -static HRESULT WINAPI Parser_OutputPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE * pmt) +static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *pmt) { - Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface); + Parser_OutputPin *This = (Parser_OutputPin *)pin; - TRACE("()\n"); dump_AM_MEDIA_TYPE(pmt); return (memcmp(This->pmt, pmt, sizeof(AM_MEDIA_TYPE)) == 0); @@ -722,7 +722,7 @@ static const IPinVtbl Parser_OutputPin_Vtbl = BasePinImpl_QueryPinInfo, BasePinImpl_QueryDirection, BasePinImpl_QueryId, - Parser_OutputPin_QueryAccept, + BasePinImpl_QueryAccept, BasePinImpl_EnumMediaTypes, BasePinImpl_QueryInternalConnections, BaseOutputPinImpl_EndOfStream, diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f26e114734..5da4269676 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -39,7 +39,7 @@ reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29 reactos/dll/directx/wine/dxdiagn # Synced to WineStaging-3.3 reactos/dll/directx/wine/msdmo # Synced to WineStaging-3.9 reactos/dll/directx/wine/qedit # Synced to WineStaging-3.3 -reactos/dll/directx/wine/quartz # Synced to WineStaging-3.3 +reactos/dll/directx/wine/quartz # Synced to WineStaging-3.9 reactos/dll/directx/wine/wined3d # Synced to WineStaging-3.9 reactos/dll/win32/activeds # Synced to WineStaging-3.3
6 years, 7 months
1
0
0
0
01/01: [MSDMO] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=20e02be701087f1690258…
commit 20e02be701087f1690258acfb71803d9e8423168 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 03:59:47 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 03:59:47 2018 +0100 [MSDMO] Sync with Wine Staging 3.9. CORE-14656 --- dll/directx/wine/msdmo/dmoreg.c | 58 +++++++++++++++++++++++++---------------- media/doc/README.WINE | 2 +- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/dll/directx/wine/msdmo/dmoreg.c b/dll/directx/wine/msdmo/dmoreg.c index 67ba498bc4..2161d40af6 100644 --- a/dll/directx/wine/msdmo/dmoreg.c +++ b/dll/directx/wine/msdmo/dmoreg.c @@ -29,7 +29,6 @@ #include "objbase.h" #include "wine/unicode.h" #include "wine/debug.h" -#include "initguid.h" #include "dmo.h" WINE_DEFAULT_DEBUG_CHANNEL(msdmo); @@ -118,6 +117,16 @@ static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid) return lpwstr; } +static HRESULT string_to_guid(const WCHAR *string, GUID *guid) +{ + WCHAR buffer[39]; + buffer[0] = '{'; + strcpyW(buffer + 1, string); + buffer[37] = '}'; + buffer[38] = 0; + return CLSIDFromString(buffer, guid); +} + static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2) { @@ -391,7 +400,6 @@ static HRESULT IEnumDMO_Constructor( { IEnumDMOImpl* lpedmo; HRESULT hr; - LONG ret; *obj = NULL; @@ -406,6 +414,7 @@ static HRESULT IEnumDMO_Constructor( lpedmo->dwFlags = dwFlags; lpedmo->cInTypes = cInTypes; lpedmo->cOutTypes = cOutTypes; + lpedmo->hkey = NULL; hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes); if (FAILED(hr)) @@ -418,8 +427,7 @@ static HRESULT IEnumDMO_Constructor( /* If not filtering by category enum from media objects root */ if (IsEqualGUID(guidCategory, &GUID_NULL)) { - if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey))) - hr = HRESULT_FROM_WIN32(ret); + RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey); } else { @@ -427,8 +435,7 @@ static HRESULT IEnumDMO_Constructor( WCHAR szKey[MAX_PATH]; wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory)); - if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey))) - hr = HRESULT_FROM_WIN32(ret); + RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey); } lerr: @@ -517,14 +524,18 @@ static HRESULT WINAPI IEnumDMO_fnNext( UINT count = 0; HRESULT hres = S_OK; LONG ret; + GUID guid; IEnumDMOImpl *This = impl_from_IEnumDMO(iface); TRACE("(%p)->(%d %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched); - if (!pCLSID || !Names || !pcItemsFetched) + if (!pCLSID || !Names) return E_POINTER; + if (!pcItemsFetched && cItemsToFetch > 1) + return E_INVALIDARG; + while (count < cItemsToFetch) { This->index++; @@ -537,6 +548,9 @@ static HRESULT WINAPI IEnumDMO_fnNext( break; } + if (string_to_guid(szNextKey, &guid) != S_OK) + continue; + TRACE("found %s\n", debugstr_w(szNextKey)); if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED)) @@ -571,7 +585,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( continue; } - pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue; + pInTypes = (DMO_PARTIAL_MEDIATYPE *)szValue; TRACE("read %d intypes for %s:\n", cInTypes, debugstr_w(szKey)); for (i = 0; i < cInTypes; i++) { @@ -584,10 +598,10 @@ static HRESULT WINAPI IEnumDMO_fnNext( for (j = 0; j < cInTypes; j++) { if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i])) - break; + break; } - if (j >= cInTypes) + if (j >= cInTypes) break; } @@ -608,13 +622,13 @@ static HRESULT WINAPI IEnumDMO_fnNext( sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE), (DMO_PARTIAL_MEDIATYPE*)szValue); - if (FAILED(hres)) + if (FAILED(hres)) { RegCloseKey(hkey); continue; } - pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue; + pOutTypes = (DMO_PARTIAL_MEDIATYPE *)szValue; TRACE("read %d outtypes for %s:\n", cOutTypes, debugstr_w(szKey)); for (i = 0; i < cOutTypes; i++) { @@ -627,10 +641,10 @@ static HRESULT WINAPI IEnumDMO_fnNext( for (j = 0; j < cOutTypes; j++) { if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i])) - break; + break; } - if (j >= cOutTypes) + if (j >= cOutTypes) break; } @@ -641,26 +655,26 @@ static HRESULT WINAPI IEnumDMO_fnNext( } } - /* Media object wasn't filtered so add it to return list */ + /* Media object wasn't filtered so add it to return list */ Names[count] = NULL; - len = MAX_PATH * sizeof(WCHAR); + len = MAX_PATH * sizeof(WCHAR); ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len); if (ERROR_SUCCESS == ret) - { + { Names[count] = CoTaskMemAlloc((strlenW(szValue) + 1) * sizeof(WCHAR)); - if (Names[count]) + if (Names[count]) strcpyW(Names[count], szValue); - } + } wsprintfW(szGuidKey,szToGuidFmt,szNextKey); CLSIDFromString(szGuidKey, &pCLSID[count]); TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey)); RegCloseKey(hkey); - count++; + count++; } - *pcItemsFetched = count; - if (*pcItemsFetched < cItemsToFetch) + if (pcItemsFetched) *pcItemsFetched = count; + if (count < cItemsToFetch) hres = S_FALSE; TRACE("<-- %i found\n",count); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 521d2b05d6..f26e114734 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -37,7 +37,7 @@ reactos/dll/directx/wine/dplay # Synced to WineStaging-3.3 reactos/dll/directx/wine/dplayx # Synced to WineStaging-3.3 reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29 reactos/dll/directx/wine/dxdiagn # Synced to WineStaging-3.3 -reactos/dll/directx/wine/msdmo # Synced to WineStaging-3.3 +reactos/dll/directx/wine/msdmo # Synced to WineStaging-3.9 reactos/dll/directx/wine/qedit # Synced to WineStaging-3.3 reactos/dll/directx/wine/quartz # Synced to WineStaging-3.3 reactos/dll/directx/wine/wined3d # Synced to WineStaging-3.9
6 years, 7 months
1
0
0
0
01/01: [DMUSIC] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e467e5ff1b2cd88725c74…
commit e467e5ff1b2cd88725c74a135d0e8621bcaa3ec4 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 03:59:04 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 03:59:04 2018 +0100 [DMUSIC] Sync with Wine Staging 3.9. CORE-14656 --- dll/directx/wine/dmusic/port.c | 4 ++-- media/doc/README.WINE | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/directx/wine/dmusic/port.c b/dll/directx/wine/dmusic/port.c index 50646153a7..713175650b 100644 --- a/dll/directx/wine/dmusic/port.c +++ b/dll/directx/wine/dmusic/port.c @@ -510,7 +510,7 @@ static HRESULT WINAPI synth_dmport_SetDirectSound(IDirectMusicPort *iface, IDire This->parent->dsound = NULL; } if (This->dsbuffer) - IDirectSound_Release(This->dsbuffer); + IDirectSoundBuffer_Release(This->dsbuffer); This->dsound = dsound; This->dsbuffer = dsbuffer; @@ -518,7 +518,7 @@ static HRESULT WINAPI synth_dmport_SetDirectSound(IDirectMusicPort *iface, IDire if (This->dsound) IDirectSound_AddRef(This->dsound); if (This->dsbuffer) - IDirectSound_AddRef(This->dsbuffer); + IDirectSoundBuffer_AddRef(This->dsbuffer); return S_OK; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index ad529a327c..521d2b05d6 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -32,7 +32,7 @@ reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.9 reactos/dll/directx/wine/devenum # Synced to WineStaging-3.9 reactos/dll/directx/wine/dinput # Synced to WineStaging-3.9 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-3.3 -reactos/dll/directx/wine/dmusic # Synced to WineStaging-3.3 +reactos/dll/directx/wine/dmusic # Synced to WineStaging-3.9 reactos/dll/directx/wine/dplay # Synced to WineStaging-3.3 reactos/dll/directx/wine/dplayx # Synced to WineStaging-3.3 reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29
6 years, 7 months
1
0
0
0
01/01: [DINPUT_WINETEST] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=979d53be2a11d7651fd45…
commit 979d53be2a11d7651fd45c742705021ff1fee4dc Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 03:58:11 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 03:58:11 2018 +0100 [DINPUT_WINETEST] Sync with Wine Staging 3.9. CORE-14656 --- modules/rostests/winetests/dinput/keyboard.c | 193 ++++++++++++++++++++++++++- modules/rostests/winetests/dinput/mouse.c | 23 +++- 2 files changed, 213 insertions(+), 3 deletions(-) diff --git a/modules/rostests/winetests/dinput/keyboard.c b/modules/rostests/winetests/dinput/keyboard.c index e51e332535..576a94cc7d 100644 --- a/modules/rostests/winetests/dinput/keyboard.c +++ b/modules/rostests/winetests/dinput/keyboard.c @@ -30,6 +30,53 @@ #include "wingdi.h" #include "dinput.h" +/* to make things easier with PSDK without a dinput.lib */ +static HRESULT (WINAPI *pDirectInputCreateA)(HINSTANCE,DWORD,IDirectInputA **,IUnknown *); + +static void pump_messages(void) +{ + MSG msg; + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } +} + +static HKL activate_keyboard_layout(LANGID langid, HKL *hkl_orig) +{ + HKL hkl, hkl_current; + char hkl_name[64]; + + sprintf(hkl_name, "%08x", langid); + trace("Loading keyboard layout %s\n", hkl_name); + hkl = LoadKeyboardLayoutA(hkl_name, 0); + if (!hkl) + { + win_skip("Unable to load keyboard layout %s\n", hkl_name); + return 0; + } + *hkl_orig = ActivateKeyboardLayout(hkl, 0); + ok(*hkl_orig != 0, "Unable to activate keyboard layout %s\n", hkl_name); + if (!*hkl_orig) return 0; + + hkl_current = GetKeyboardLayout(0); + if (LOWORD(hkl_current) != langid) + { + /* FIXME: Wine can't activate different keyboard layouts. + * for testing purposes use this workaround: + * setxkbmap us && LANG=en_US.UTF-8 make test + * setxkbmap fr && LANG=fr_FR.UTF-8 make test + * setxkbmap de && LANG=de_DE.UTF-8 make test + */ + skip("current %08x != langid %08x\n", LOWORD(hkl_current), langid); + return 0; + } + + return hkl; +} + static void acquire_tests(IDirectInputA *pDI, HWND hwnd) { HRESULT hr; @@ -44,8 +91,12 @@ static void acquire_tests(IDirectInputA *pDI, HWND hwnd) { &GUID_Key, sizeof(LONG) * 2, DIDFT_MAKEINSTANCE(DIK_E)|DIDFT_BUTTON, 0 }, { &GUID_Key, sizeof(LONG) * 4, DIDFT_MAKEINSTANCE(DIK_R)|DIDFT_BUTTON, 0 }, }; - DIDATAFORMAT df; + HKL hkl, hkl_orig; + + hkl = activate_keyboard_layout(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), &hkl_orig); + if (!hkl) return; + df.dwSize = sizeof( df ); df.dwObjSize = sizeof( DIOBJECTDATAFORMAT ); df.dwFlags = DIDF_RELAXIS; @@ -93,6 +144,8 @@ static void acquire_tests(IDirectInputA *pDI, HWND hwnd) /* simulate some keyboard input */ SetFocus(hwnd); + pump_messages(); + keybd_event('Q', 0, 0, 0); hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state); ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr); @@ -113,6 +166,9 @@ static void acquire_tests(IDirectInputA *pDI, HWND hwnd) keybd_event('Q', 0, KEYEVENTF_KEYUP, 0); if (pKeyboard) IUnknown_Release(pKeyboard); + + ActivateKeyboardLayout(hkl_orig, 0); + UnloadKeyboardLayout(hkl); } static const HRESULT SetCoop_null_window[16] = { @@ -225,6 +281,130 @@ static void test_capabilities(IDirectInputA *pDI, HWND hwnd) IUnknown_Release(pKeyboard); } +static void test_dik_codes(IDirectInputA *dI, HWND hwnd, LANGID langid) +{ + static const struct key2dik + { + BYTE key, dik; + } key2dik_en[] = + { + {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y} + }, + key2dik_fr[] = + { + {'A',DIK_Q}, {'Z',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y} + }, + key2dik_de[] = + { + {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Z',DIK_Y} + }; + static const struct + { + LANGID langid; + const struct key2dik *map; + } expected[] = + { + { MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), key2dik_en }, + { MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), key2dik_fr }, + { MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), key2dik_de }, + { MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), key2dik_en } + }; + const struct key2dik *map = NULL; + UINT i; + HRESULT hr; + IDirectInputDeviceA *device; + HKL hkl, hkl_orig; + MSG msg; + + for (i = 0; i < sizeof(expected)/sizeof(expected[0]); i++) + { + if (expected[i].langid == langid) + { + map = expected[i].map; + break; + } + } + ok(map != NULL, "can't find mapping for langid %04x\n", langid); + if (!map) return; + + hr = IDirectInput_CreateDevice(dI, &GUID_SysKeyboard, &device, NULL); + ok(hr == S_OK, "CreateDevice() failed: %08x\n", hr); + hr = IDirectInputDevice_SetDataFormat(device, &c_dfDIKeyboard); + ok(hr == S_OK, "SetDataFormat() failed: %08x\n", hr); + hr = IDirectInputDevice_Acquire(device); + ok(hr == S_OK, "Acquire() failed: %08x\n", hr); + + hkl = activate_keyboard_layout(langid, &hkl_orig); + if (!hkl) goto fail; + + SetFocus(hwnd); + pump_messages(); + + for (i = 0; i < sizeof(key2dik_en)/sizeof(key2dik_en[0]); i++) + { + BYTE kbd_state[256]; + UINT n; + INPUT in; + + n = MapVirtualKeyA(map[i].key, MAPVK_VK_TO_CHAR); + ok(n == map[i].key, "%u: expected %c, got %c\n", i, map[i].key, n); + n = MapVirtualKeyA(map[i].key, MAPVK_VK_TO_VSC); + ok(n == map[i].dik, "%u: expected %02x, got %02x\n", i, map[i].dik, n); + + in.type = INPUT_KEYBOARD; + U(in).ki.wVk = map[i].key; + U(in).ki.wScan = map[i].dik; /* scan codes match the DIK_ codes */ + U(in).ki.dwFlags = 0; + U(in).ki.dwExtraInfo = 0; + U(in).ki.time = 0; + n = SendInput(1, &in, sizeof(in)); + ok(n == 1, "got %u\n", n); + + if (!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + { + win_skip("failed to queue keyboard event\n"); + break; + } + ok(msg.message == WM_KEYDOWN || broken(msg.message != WM_KEYDOWN), "expected WM_KEYDOWN, got %04x\n", msg.message); + /* this never happens on real hardware but tesbot VMs seem to have timing issues */ + if (msg.message != WM_KEYDOWN) + { + win_skip("failed to queue keyboard event\n"); + break; + } + DispatchMessageA(&msg); + + trace("keydown wParam: %#lx (%c) lParam: %#lx, MapVirtualKey(MAPVK_VK_TO_CHAR) = %c\n", + msg.wParam, LOWORD(msg.wParam), msg.lParam, MapVirtualKeyA(msg.wParam, MAPVK_VK_TO_CHAR)); + + pump_messages(); + + hr = IDirectInputDevice_GetDeviceState(device, sizeof(kbd_state), kbd_state); + ok(hr == S_OK, "GetDeviceState() failed: %08x\n", hr); + + /* this never happens on real hardware but tesbot VMs seem to have timing issues */ + if (i == 0 && kbd_state[map[0].dik] != 0x80) + { + win_skip("dinput failed to handle keyboard event\n"); + break; + } + + ok(kbd_state[map[i].dik] == 0x80, "DI key %#x has state %#x\n", map[i].dik, kbd_state[map[i].dik]); + + U(in).ki.dwFlags = KEYEVENTF_KEYUP; + n = SendInput(1, &in, sizeof(in)); + ok(n == 1, "got %u\n", n); + + pump_messages(); + } + + ActivateKeyboardLayout(hkl_orig, 0); + UnloadKeyboardLayout(hkl); +fail: + IDirectInputDevice_Unacquire(device); + IUnknown_Release(device); +} + static void keyboard_tests(DWORD version) { HRESULT hr; @@ -233,7 +413,7 @@ static void keyboard_tests(DWORD version) HWND hwnd; ULONG ref = 0; - hr = DirectInputCreateA(hInstance, version, &pDI, NULL); + hr = pDirectInputCreateA(hInstance, version, &pDI, NULL); if (hr == DIERR_OLDDIRECTINPUTVERSION) { skip("Tests require a newer dinput version\n"); @@ -248,10 +428,17 @@ static void keyboard_tests(DWORD version) if (hwnd) { + pump_messages(); + acquire_tests(pDI, hwnd); test_set_coop(pDI, hwnd); test_get_prop(pDI, hwnd); test_capabilities(pDI, hwnd); + + test_dik_codes(pDI, hwnd, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT)); + test_dik_codes(pDI, hwnd, MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH)); + test_dik_codes(pDI, hwnd, MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN)); + test_dik_codes(pDI, hwnd, MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN)); } DestroyWindow(hwnd); @@ -261,6 +448,8 @@ static void keyboard_tests(DWORD version) START_TEST(keyboard) { + pDirectInputCreateA = (void *)GetProcAddress(LoadLibraryA("dinput.dll"), "DirectInputCreateA"); + CoInitialize(NULL); keyboard_tests(0x0700); diff --git a/modules/rostests/winetests/dinput/mouse.c b/modules/rostests/winetests/dinput/mouse.c index 7f71b6e6e7..c1a8143d21 100644 --- a/modules/rostests/winetests/dinput/mouse.c +++ b/modules/rostests/winetests/dinput/mouse.c @@ -165,7 +165,7 @@ else { hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); - /* Check for buffer owerflow */ + /* Check for buffer overflow */ for (i = 0; i < 6; i++) mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0); @@ -175,6 +175,27 @@ else { cnt = 1; hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + + /* Check for granularity property using BYOFFSET */ + memset(&di_op, 0, sizeof(di_op)); + di_op.diph.dwHow = DIPH_BYOFFSET; + di_op.diph.dwObj = DIMOFS_Y; + di_op.diph.dwSize = sizeof(DIPROPDWORD); + di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); + hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); + /* Granularity of Y axis should be 1! */ + ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %08x, dwData: %i but should be 1.\n", hr, di_op.dwData); + + /* Check for granularity property using BYID */ + memset(&di_op, 0, sizeof(di_op)); + di_op.diph.dwHow = DIPH_BYID; + /* WINE_MOUSE_Y_AXIS_INSTANCE := 1 */ + di_op.diph.dwObj = (DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS); + di_op.diph.dwSize = sizeof(DIPROPDWORD); + di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); + hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); + /* Granularity of Y axis should be 1! */ + ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %08x, dwData: %i but should be 1.\n", hr, di_op.dwData); } if (pMouse) IUnknown_Release(pMouse);
6 years, 7 months
1
0
0
0
01/01: [DINPUT] Sync with Wine Staging 3.9. CORE-14656
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e2ded18d65f338812d7a2…
commit e2ded18d65f338812d7a208059d0e1e991c57641 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun May 27 03:57:38 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun May 27 03:57:38 2018 +0100 [DINPUT] Sync with Wine Staging 3.9. CORE-14656 --- dll/directx/wine/dinput/keyboard.c | 27 ++++++--------------------- dll/directx/wine/dinput/mouse.c | 17 +++++++++++++++-- media/doc/README.WINE | 2 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/dll/directx/wine/dinput/keyboard.c b/dll/directx/wine/dinput/keyboard.c index 4c3c38e7fc..8a59ce01bc 100644 --- a/dll/directx/wine/dinput/keyboard.c +++ b/dll/directx/wine/dinput/keyboard.c @@ -69,26 +69,10 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardIm static BYTE map_dik_code(DWORD scanCode, DWORD vkCode) { - static const BYTE asciiCodes[] = - {/*32*/ DIK_SPACE,0,0,0,0,0,0,DIK_APOSTROPHE, - /*40*/ 0,0,0,0,DIK_COMMA,DIK_MINUS,DIK_PERIOD,DIK_SLASH, - /*48*/ DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7, - /*56*/ DIK_8,DIK_9,DIK_COLON,DIK_SEMICOLON,0,DIK_EQUALS,0,0, - /*64*/ DIK_AT,DIK_A,DIK_B,DIK_C,DIK_D,DIK_E,DIK_F,DIK_G, - /*72*/ DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O, - /*80*/ DIK_P,DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W, - /*88*/ DIK_X,DIK_Y,DIK_Z,DIK_LBRACKET,0,DIK_RBRACKET,DIK_CIRCUMFLEX,DIK_UNDERLINE} /*95*/ ; - - BYTE out_code = 0; - WCHAR c = MapVirtualKeyW(vkCode,MAPVK_VK_TO_CHAR); - - if (c > 31 && c < 96) - out_code = asciiCodes[c - 32]; - - if (out_code == 0) - out_code = scanCode; - - return out_code; + if (!scanCode) + scanCode = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC); + + return scanCode; } static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam ) @@ -102,7 +86,8 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP) return 0; - TRACE("(%p) %ld,%ld\n", iface, wparam, lparam); + TRACE("(%p) wp %08lx, lp %08lx, vk %02x, scan %02x\n", + iface, wparam, lparam, hook->vkCode, hook->scanCode); switch (hook->vkCode) { diff --git a/dll/directx/wine/dinput/mouse.c b/dll/directx/wine/dinput/mouse.c index eaec6b17dc..6d3eff5d52 100644 --- a/dll/directx/wine/dinput/mouse.c +++ b/dll/directx/wine/dinput/mouse.c @@ -616,8 +616,21 @@ static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF case (DWORD_PTR) DIPROP_GRANULARITY: { LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph; - /* We'll just assume that the app asks about the Z axis */ - pr->dwData = WHEEL_DELTA; + if ( + ((pdiph->dwHow == DIPH_BYOFFSET) && + ((pdiph->dwObj == DIMOFS_X) || + (pdiph->dwObj == DIMOFS_Y))) + || + ((pdiph->dwHow == DIPH_BYID) && + ((pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS)) || + (pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS)))) + ){ + /* Set granularity of X/Y Axis to 1. See MSDN on DIPROP_GRANULARITY */ + pr->dwData = 1; + } else { + /* We'll just assume that the app asks about the Z axis */ + pr->dwData = WHEEL_DELTA; + } break; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index a5b6b1865a..ad529a327c 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.9 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-3.3 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.9 reactos/dll/directx/wine/devenum # Synced to WineStaging-3.9 -reactos/dll/directx/wine/dinput # Synced to WineStaging-3.3 +reactos/dll/directx/wine/dinput # Synced to WineStaging-3.9 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-3.3 reactos/dll/directx/wine/dmusic # Synced to WineStaging-3.3 reactos/dll/directx/wine/dplay # Synced to WineStaging-3.3
6 years, 7 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
22
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Results per page:
10
25
50
100
200