winehq.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
2025
February
January
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
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2011
----- 2025 -----
February 2025
January 2025
----- 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
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
937 discussions
Start a n
N
ew thread
David Hedberg : comdlg32: Implement opening files with the item dialog.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: f2231f8419a80c3a9653252028658ea6c9040a91 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f2231f8419a80c3a965325202…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:32 2011 +0200 comdlg32: Implement opening files with the item dialog. --- dlls/comdlg32/cdlg.h | 1 + dlls/comdlg32/cdlg32.c | 3 +- dlls/comdlg32/itemdlg.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 3 deletions(-) diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index 00ec357..e1b341c 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -192,6 +192,7 @@ extern UINT (WINAPI *COMDLG32_PIDL_ILGetSize)(LPCITEMIDLIST); 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 #define ONOPEN_OPEN 2 diff --git a/dlls/comdlg32/cdlg32.c b/dlls/comdlg32/cdlg32.c index 4f6b98a..ad44bbb 100644 --- a/dlls/comdlg32/cdlg32.c +++ b/dlls/comdlg32/cdlg32.c @@ -57,6 +57,7 @@ UINT (WINAPI *COMDLG32_PIDL_ILGetSize)(LPCITEMIDLIST); LPVOID (WINAPI *COMDLG32_SHAlloc)(DWORD); DWORD (WINAPI *COMDLG32_SHFree)(LPVOID); BOOL (WINAPI *COMDLG32_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR); +LPITEMIDLIST (WINAPI *COMDLG32_SHSimpleIDListFromPathAW)(LPCVOID); /*********************************************************************** * DllMain (COMDLG32.init) @@ -96,7 +97,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved) 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); diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index caa2454..35910c3 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -199,6 +199,113 @@ static void fill_filename_from_selection(FileDialogImpl *This) return; } +static HRESULT on_default_action(FileDialogImpl *This) +{ + IShellFolder *psf_parent, *psf_desktop; + LPITEMIDLIST *pidla; + LPITEMIDLIST current_folder; + LPWSTR fn_iter, files, tmp_files; + UINT file_count = 0, len, i; + int open_action; + HRESULT hr, ret = E_FAIL; + + len = get_file_name(This, &tmp_files); + if(len) + { + UINT size_used; + file_count = COMDLG32_SplitFileNames(tmp_files, len, &files, &size_used); + } + if(!file_count) return E_FAIL; + + hr = SHGetIDListFromObject((IUnknown*)This->psi_folder, ¤t_folder); + if(FAILED(hr)) + { + ERR("Failed to get pidl for current directory.\n"); + return hr; + } + + TRACE("Acting on %d file(s).\n", file_count); + + pidla = HeapAlloc(GetProcessHeap(), 0, sizeof(LPITEMIDLIST) * file_count); + open_action = ONOPEN_OPEN; + fn_iter = files; + + for(i = 0; i < file_count && open_action == ONOPEN_OPEN; i++) + { + WCHAR canon_filename[MAX_PATH]; + psf_parent = NULL; + + COMDLG32_GetCanonicalPath(current_folder, fn_iter, canon_filename); + + if( (This->options & FOS_NOVALIDATE) && + !(This->options & FOS_FILEMUSTEXIST) ) + open_action = ONOPEN_OPEN; + else + open_action = ONOPEN_BROWSE; + + open_action = FILEDLG95_ValidatePathAction(canon_filename, &psf_parent, This->dlg_hwnd, + This->options, (This->dlg_type == ITEMDLG_TYPE_SAVE), + open_action); + + pidla[i] = COMDLG32_SHSimpleIDListFromPathAW(canon_filename); + + if(psf_parent && !(open_action == ONOPEN_BROWSE)) + IShellItem_Release(psf_parent); + + fn_iter += (WCHAR)lstrlenW(fn_iter) + 1; + } + + HeapFree(GetProcessHeap(), 0, files); + ILFree(current_folder); + + if((This->options & FOS_PICKFOLDERS) && open_action == ONOPEN_BROWSE) + open_action = ONOPEN_OPEN; /* FIXME: Multiple folders? */ + + switch(open_action) + { + case ONOPEN_SEARCH: + FIXME("Filtering not implemented.\n"); + break; + + case ONOPEN_BROWSE: + hr = IExplorerBrowser_BrowseToObject(This->peb, (IUnknown*)psf_parent, SBSP_DEFBROWSER); + if(FAILED(hr)) + ERR("Failed to browse to directory: %08x\n", hr); + + IShellItem_Release(psf_parent); + break; + + case ONOPEN_OPEN: + hr = SHGetDesktopFolder(&psf_desktop); + if(SUCCEEDED(hr)) + { + if(This->psia_results) + IShellItemArray_Release(This->psia_results); + + hr = SHCreateShellItemArray(NULL, psf_desktop, file_count, (PCUITEMID_CHILD_ARRAY)pidla, + &This->psia_results); + + if(SUCCEEDED(hr)) + ret = S_OK; + + IShellFolder_Release(psf_desktop); + } + break; + + default: + ERR("Failed.\n"); + break; + } + + /* Clean up */ + for(i = 0; i < file_count; i++) + ILFree(pidla[i]); + HeapFree(GetProcessHeap(), 0, pidla); + + /* Success closes the dialog */ + return ret; +} + /************************************************************************** * Window related functions. */ @@ -527,7 +634,8 @@ static LRESULT on_idok(FileDialogImpl *This) { TRACE("%p\n", This); - EndDialog(This->dlg_hwnd, S_OK); + if(SUCCEEDED(on_default_action(This))) + EndDialog(This->dlg_hwnd, S_OK); return FALSE; } @@ -1766,7 +1874,14 @@ static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *ifac IShellView *shv) { FileDialogImpl *This = impl_from_ICommDlgBrowser3(iface); - FIXME("Stub: %p (%p)\n", This, shv); + HRESULT hr; + TRACE("%p (%p)\n", This, shv); + + hr = on_default_action(This); + + if(SUCCEEDED(hr)) + EndDialog(This->dlg_hwnd, S_OK); + return S_OK; }
1
0
0
0
David Hedberg : comdlg32: Factor out filename string splitting code.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: 9c1f56f67efbccd9dac9346a61dc0d2a2f49941c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9c1f56f67efbccd9dac9346a6…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:31 2011 +0200 comdlg32: Factor out filename string splitting code. --- dlls/comdlg32/cdlg.h | 1 + dlls/comdlg32/filedlg.c | 87 ++++++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index db0421e..00ec357 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -177,6 +177,7 @@ HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile); int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction); +int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed); /* ITEMIDLIST */ diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 1e33f5a..a36cd35 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -609,6 +609,54 @@ void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, } /*********************************************************************** + * COMDLG32_SplitFileNames [internal] + * + * Creates a delimited list of filenames. + */ +int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed) +{ + UINT nStrCharCount = 0; /* index in src buffer */ + UINT nFileIndex = 0; /* index in dest buffer */ + UINT nFileCount = 0; /* number of files */ + + /* we might get single filename without any '"', + * so we need nStrLen + terminating \0 + end-of-list \0 */ + *lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) ); + *sizeUsed = 0; + + /* build delimited file list from filenames */ + while ( nStrCharCount <= nStrLen ) + { + if ( lpstrEdit[nStrCharCount]=='"' ) + { + nStrCharCount++; + while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen)) + { + (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount]; + nStrCharCount++; + } + (*lpstrFileList)[nFileIndex++] = 0; + nFileCount++; + } + nStrCharCount++; + } + + /* single, unquoted string */ + if ((nStrLen > 0) && (nFileIndex == 0) ) + { + lstrcpyW(*lpstrFileList, lpstrEdit); + nFileIndex = lstrlenW(lpstrEdit) + 1; + nFileCount = 1; + } + + /* trailing \0 */ + (*lpstrFileList)[nFileIndex++] = '\0'; + + *sizeUsed = nFileIndex; + return nFileCount; +} + +/*********************************************************************** * ArrangeCtrlPositions [internal] * * NOTE: Make sure to add testcases for any changes made here. @@ -3642,14 +3690,10 @@ static HRESULT COMDLG32_StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, con * FILEDLG95_FILENAME_GetFileNames * * Copies the filenames to a delimited string list. - * The delimiter is specified by the parameter 'separator', - * usually either a space or a nul */ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed) { FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr); - UINT nStrCharCount = 0; /* index in src buffer */ - UINT nFileIndex = 0; /* index in dest buffer */ UINT nFileCount = 0; /* number of files */ UINT nStrLen = 0; /* length of string in edit control */ LPWSTR lpstrEdit; /* buffer for string from edit control */ @@ -3663,40 +3707,7 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit)); - /* we might get single filename without any '"', - * so we need nStrLen + terminating \0 + end-of-list \0 */ - *lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) ); - *sizeUsed = 0; - - /* build delimited file list from filenames */ - while ( nStrCharCount <= nStrLen ) - { - if ( lpstrEdit[nStrCharCount]=='"' ) - { - nStrCharCount++; - while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen)) - { - (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount]; - nStrCharCount++; - } - (*lpstrFileList)[nFileIndex++] = 0; - nFileCount++; - } - nStrCharCount++; - } - - /* single, unquoted string */ - if ((nStrLen > 0) && (nFileIndex == 0) ) - { - lstrcpyW(*lpstrFileList, lpstrEdit); - nFileIndex = lstrlenW(lpstrEdit) + 1; - nFileCount = 1; - } - - /* trailing \0 */ - (*lpstrFileList)[nFileIndex++] = '\0'; - - *sizeUsed = nFileIndex; + nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed); MemFree(lpstrEdit); return nFileCount; }
1
0
0
0
David Hedberg : comdlg32: Factor out some path validating code from FILEDLG95_OnOpen.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: 7f5ccd32627c6c25afdbead35333580ac96f37c5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7f5ccd32627c6c25afdbead35…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:30 2011 +0200 comdlg32: Factor out some path validating code from FILEDLG95_OnOpen. --- dlls/comdlg32/cdlg.h | 6 + dlls/comdlg32/filedlg.c | 252 ++++++++++++++++++++++++----------------------- 2 files changed, 135 insertions(+), 123 deletions(-) diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index fb6280d..db0421e 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -175,6 +175,8 @@ HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) /* Shared helper functions */ void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile); +int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, + HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction); /* ITEMIDLIST */ @@ -190,4 +192,8 @@ extern LPVOID (WINAPI *COMDLG32_SHAlloc)(DWORD); extern DWORD (WINAPI *COMDLG32_SHFree)(LPVOID); extern BOOL (WINAPI *COMDLG32_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR); +#define ONOPEN_BROWSE 1 +#define ONOPEN_OPEN 2 +#define ONOPEN_SEARCH 3 + #endif /* _WINE_DLL_CDLG_H */ diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 84b4eeb..1e33f5a 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -2211,16 +2211,6 @@ static void FILEDLG95_MRU_load_filename(LPWSTR stored_path) TRACE("got MRU path: %s\n", wine_dbgstr_w(stored_path)); } -/*********************************************************************** - * FILEDLG95_OnOpen - * - * Ok button WM_COMMAND message handler - * - * If the function succeeds, the return value is nonzero. - */ -#define ONOPEN_BROWSE 1 -#define ONOPEN_OPEN 2 -#define ONOPEN_SEARCH 3 static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) { WCHAR strMsgTitle[MAX_PATH]; @@ -2233,6 +2223,130 @@ static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND); } +int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, + HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction) +{ + int nOpenAction = defAction; + LPWSTR lpszTemp, lpszTemp1; + LPITEMIDLIST pidl = NULL; + static const WCHAR szwInvalid[] = { '/',':','<','>','|', 0}; + + /* check for invalid chars */ + if((strpbrkW(lpstrPathAndFile+3, szwInvalid) != NULL) && !(flags & OFN_NOVALIDATE)) + { + FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME); + return FALSE; + } + + if (FAILED (SHGetDesktopFolder(ppsf))) return FALSE; + + lpszTemp1 = lpszTemp = lpstrPathAndFile; + while (lpszTemp1) + { + LPSHELLFOLDER lpsfChild; + WCHAR lpwstrTemp[MAX_PATH]; + DWORD dwEaten, dwAttributes; + LPWSTR p; + + lstrcpyW(lpwstrTemp, lpszTemp); + p = PathFindNextComponentW(lpwstrTemp); + + if (!p) break; /* end of path */ + + *p = 0; + lpszTemp = lpszTemp + lstrlenW(lpwstrTemp); + + /* There are no wildcards when OFN_NOVALIDATE is set */ + if(*lpszTemp==0 && !(flags & OFN_NOVALIDATE)) + { + static const WCHAR wszWild[] = { '*', '?', 0 }; + /* if the last element is a wildcard do a search */ + if(strpbrkW(lpszTemp1, wszWild) != NULL) + { + nOpenAction = ONOPEN_SEARCH; + break; + } + } + lpszTemp1 = lpszTemp; + + TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), *ppsf); + + /* append a backslash to drive letters */ + if(lstrlenW(lpwstrTemp)==2 && lpwstrTemp[1] == ':' && + ((lpwstrTemp[0] >= 'a' && lpwstrTemp[0] <= 'z') || + (lpwstrTemp[0] >= 'A' && lpwstrTemp[0] <= 'Z'))) + { + PathAddBackslashW(lpwstrTemp); + } + + dwAttributes = SFGAO_FOLDER; + if(SUCCEEDED(IShellFolder_ParseDisplayName(*ppsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes))) + { + /* the path component is valid, we have a pidl of the next path component */ + TRACE("parse OK attr=0x%08x pidl=%p\n", dwAttributes, pidl); + if(dwAttributes & SFGAO_FOLDER) + { + if(FAILED(IShellFolder_BindToObject(*ppsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild))) + { + ERR("bind to failed\n"); /* should not fail */ + break; + } + IShellFolder_Release(*ppsf); + *ppsf = lpsfChild; + lpsfChild = NULL; + } + else + { + TRACE("value\n"); + + /* end dialog, return value */ + nOpenAction = ONOPEN_OPEN; + break; + } + COMDLG32_SHFree(pidl); + pidl = NULL; + } + else if (!(flags & OFN_NOVALIDATE)) + { + if(*lpszTemp || /* points to trailing null for last path element */ + (lpwstrTemp[strlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */ + { + if(flags & OFN_PATHMUSTEXIST) + { + FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING); + break; + } + } + else + { + if( (flags & OFN_FILEMUSTEXIST) && !isSaveDlg ) + { + FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING); + break; + } + } + /* change to the current folder */ + nOpenAction = ONOPEN_OPEN; + break; + } + else + { + nOpenAction = ONOPEN_OPEN; + break; + } + } + if(pidl) COMDLG32_SHFree(pidl); + + return nOpenAction; +} + +/*********************************************************************** + * FILEDLG95_OnOpen + * + * Ok button WM_COMMAND message handler + * + * If the function succeeds, the return value is nonzero. + */ BOOL FILEDLG95_OnOpen(HWND hwnd) { LPWSTR lpstrFileList; @@ -2294,120 +2408,12 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) else nOpenAction = ONOPEN_BROWSE; - /* don't apply any checks with OFN_NOVALIDATE */ - { - LPWSTR lpszTemp, lpszTemp1; - LPITEMIDLIST pidl = NULL; - static const WCHAR szwInvalid[] = { '/',':','<','>','|', 0}; - - /* check for invalid chars */ - if((strpbrkW(lpstrPathAndFile+3, szwInvalid) != NULL) && !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE)) - { - FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME); - ret = FALSE; + nOpenAction = FILEDLG95_ValidatePathAction(lpstrPathAndFile, &lpsf, hwnd, + fodInfos->ofnInfos->Flags, + fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG, + nOpenAction); + if(!nOpenAction) goto ret; - } - - if (FAILED (SHGetDesktopFolder(&lpsf))) return FALSE; - - lpszTemp1 = lpszTemp = lpstrPathAndFile; - while (lpszTemp1) - { - LPSHELLFOLDER lpsfChild; - WCHAR lpwstrTemp[MAX_PATH]; - DWORD dwEaten, dwAttributes; - LPWSTR p; - - lstrcpyW(lpwstrTemp, lpszTemp); - p = PathFindNextComponentW(lpwstrTemp); - - if (!p) break; /* end of path */ - - *p = 0; - lpszTemp = lpszTemp + lstrlenW(lpwstrTemp); - - /* There are no wildcards when OFN_NOVALIDATE is set */ - if(*lpszTemp==0 && !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE)) - { - static const WCHAR wszWild[] = { '*', '?', 0 }; - /* if the last element is a wildcard do a search */ - if(strpbrkW(lpszTemp1, wszWild) != NULL) - { - nOpenAction = ONOPEN_SEARCH; - break; - } - } - lpszTemp1 = lpszTemp; - - TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), lpsf); - - /* append a backslash to drive letters */ - if(lstrlenW(lpwstrTemp)==2 && lpwstrTemp[1] == ':' && - ((lpwstrTemp[0] >= 'a' && lpwstrTemp[0] <= 'z') || - (lpwstrTemp[0] >= 'A' && lpwstrTemp[0] <= 'Z'))) - { - PathAddBackslashW(lpwstrTemp); - } - - dwAttributes = SFGAO_FOLDER; - if(SUCCEEDED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes))) - { - /* the path component is valid, we have a pidl of the next path component */ - TRACE("parse OK attr=0x%08x pidl=%p\n", dwAttributes, pidl); - if(dwAttributes & SFGAO_FOLDER) - { - if(FAILED(IShellFolder_BindToObject(lpsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild))) - { - ERR("bind to failed\n"); /* should not fail */ - break; - } - IShellFolder_Release(lpsf); - lpsf = lpsfChild; - lpsfChild = NULL; - } - else - { - TRACE("value\n"); - - /* end dialog, return value */ - nOpenAction = ONOPEN_OPEN; - break; - } - COMDLG32_SHFree(pidl); - pidl = NULL; - } - else if (!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE)) - { - if(*lpszTemp || /* points to trailing null for last path element */ - (lpwstrTemp[strlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */ - { - if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST) - { - FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING); - break; - } - } - else - { - if( (fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) && - !( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) ) - { - FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING); - break; - } - } - /* change to the current folder */ - nOpenAction = ONOPEN_OPEN; - break; - } - else - { - nOpenAction = ONOPEN_OPEN; - break; - } - } - if(pidl) COMDLG32_SHFree(pidl); - } /* Step 3: here we have a cleaned up and validated path
1
0
0
0
David Hedberg : comdlg32: Factor out some path building code from FILEDLG95_OnOpen.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: fcb169fe3667126ed256867114c35b39c0ad6cc4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fcb169fe3667126ed25686711…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:29 2011 +0200 comdlg32: Factor out some path building code from FILEDLG95_OnOpen. --- dlls/comdlg32/cdlg.h | 3 ++ dlls/comdlg32/filedlg.c | 71 +++++++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index 17492a3..fb6280d 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -173,6 +173,9 @@ typedef struct { HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv); HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv); +/* Shared helper functions */ +void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile); + /* ITEMIDLIST */ extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST); diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index c65c1f7..84b4eeb 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -568,6 +568,46 @@ static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) { return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH)); } +/****************************************************************************** + * COMDLG32_GetCanonicalPath [internal] + * + * Helper function to get the canonical path. + */ +void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, + LPWSTR lpstrFile, LPWSTR lpstrPathAndFile) +{ + WCHAR lpstrTemp[MAX_PATH]; + + /* Get the current directory name */ + if (!COMDLG32_GetDisplayNameOf(pidlAbsCurrent, lpstrPathAndFile)) + { + /* last fallback */ + GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile); + } + PathAddBackslashW(lpstrPathAndFile); + + TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile)); + + /* if the user specified a fully qualified path use it */ + if(PathIsRelativeW(lpstrFile)) + { + lstrcatW(lpstrPathAndFile, lpstrFile); + } + else + { + /* does the path have a drive letter? */ + if (PathGetDriveNumberW(lpstrFile) == -1) + lstrcpyW(lpstrPathAndFile+2, lpstrFile); + else + lstrcpyW(lpstrPathAndFile, lpstrFile); + } + + /* resolve "." and ".." */ + PathCanonicalizeW(lpstrTemp, lpstrPathAndFile ); + lstrcpyW(lpstrPathAndFile, lpstrTemp); + TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile)); +} + /*********************************************************************** * ArrangeCtrlPositions [internal] * @@ -2200,7 +2240,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) UINT sizeUsed = 0; BOOL ret = TRUE; WCHAR lpstrPathAndFile[MAX_PATH]; - WCHAR lpstrTemp[MAX_PATH]; LPSHELLFOLDER lpsf = NULL; int nOpenAction; FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr); @@ -2234,35 +2273,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) - the edit box contains ".." (or a path with ".." in it) */ - /* Get the current directory name */ - if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile)) - { - /* last fallback */ - GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile); - } - PathAddBackslashW(lpstrPathAndFile); - - TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile)); - - /* if the user specified a fully qualified path use it */ - if(PathIsRelativeW(lpstrFileList)) - { - lstrcatW(lpstrPathAndFile, lpstrFileList); - } - else - { - /* does the path have a drive letter? */ - if (PathGetDriveNumberW(lpstrFileList) == -1) - lstrcpyW(lpstrPathAndFile+2, lpstrFileList); - else - lstrcpyW(lpstrPathAndFile, lpstrFileList); - } - - /* resolve "." and ".." */ - PathCanonicalizeW(lpstrTemp, lpstrPathAndFile ); - lstrcpyW(lpstrPathAndFile, lpstrTemp); - TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile)); - + COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile); MemFree(lpstrFileList); /*
1
0
0
0
David Hedberg : comdlg32: Add a couple of simple navigation buttons to the item dialog.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: a172365bd94126c7083248ac1575f25fbf6b4914 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a172365bd94126c7083248ac1…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:28 2011 +0200 comdlg32: Add a couple of simple navigation buttons to the item dialog. --- dlls/comdlg32/itemdlg.c | 68 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 65 insertions(+), 3 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 0d75c33..caa2454 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -38,6 +38,10 @@ #include "wine/debug.h" #include "wine/list.h" +#define IDC_NAV_TOOLBAR 200 +#define IDC_NAVBACK 201 +#define IDC_NAVFORWARD 202 + WINE_DEFAULT_DEBUG_CHANNEL(commdlg); enum ITEMDLG_TYPE { @@ -205,7 +209,7 @@ static SIZE update_layout(FileDialogImpl *This) RECT dialog_rc; RECT cancel_rc, open_rc; RECT filetype_rc, filename_rc, filenamelabel_rc; - RECT ebrowser_rc; + RECT toolbar_rc, ebrowser_rc; int missing_width, missing_height; static const UINT vspacing = 4, hspacing = 4; SIZE ret; @@ -308,10 +312,17 @@ static SIZE update_layout(FileDialogImpl *This) filename_rc.bottom = filename_rc.top + filename_height; } + hwnd = GetDlgItem(This->dlg_hwnd, IDC_NAV_TOOLBAR); + if(hwnd) + { + GetWindowRect(hwnd, &toolbar_rc); + MapWindowPoints(NULL, This->dlg_hwnd, (POINT*)&toolbar_rc, 2); + } + /* The ExplorerBrowser control. */ ebrowser_rc.left = dialog_rc.left + vspacing; - ebrowser_rc.top = 0; - ebrowser_rc.right = dialog_rc.right - vspacing; + ebrowser_rc.top = toolbar_rc.bottom + vspacing; + ebrowser_rc.right = dialog_rc.right - hspacing; ebrowser_rc.bottom = filename_rc.top - hspacing; /**** @@ -405,10 +416,44 @@ static HRESULT init_explorerbrowser(FileDialogImpl *This) return S_OK; } +static void init_toolbar(FileDialogImpl *This, HWND hwnd) +{ + HWND htoolbar; + TBADDBITMAP tbab; + TBBUTTON button[2]; + + htoolbar = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL, TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE, + 0, 0, 0, 0, + hwnd, (HMENU)IDC_NAV_TOOLBAR, NULL, NULL); + + tbab.hInst = HINST_COMMCTRL; + tbab.nID = IDB_HIST_LARGE_COLOR; + SendMessageW(htoolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab); + + button[0].iBitmap = HIST_BACK; + button[0].idCommand = IDC_NAVBACK; + button[0].fsState = TBSTATE_ENABLED; + button[0].fsStyle = BTNS_BUTTON; + button[0].dwData = 0; + button[0].iString = 0; + + button[1].iBitmap = HIST_FORWARD; + button[1].idCommand = IDC_NAVFORWARD; + button[1].fsState = TBSTATE_ENABLED; + button[1].fsStyle = BTNS_BUTTON; + button[1].dwData = 0; + button[1].iString = 0; + + SendMessageW(htoolbar, TB_ADDBUTTONSW, 2, (LPARAM)&button); + SendMessageW(htoolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(24,24)); + SendMessageW(htoolbar, TB_AUTOSIZE, 0, 0); +} + static LRESULT on_wm_initdialog(HWND hwnd, LPARAM lParam) { FileDialogImpl *This = (FileDialogImpl*)lParam; HWND hitem; + TRACE("(%p, %p)\n", This, hwnd); SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This); @@ -438,6 +483,7 @@ static LRESULT on_wm_initdialog(HWND hwnd, LPARAM lParam) SendMessageW(hitem, WM_SETTEXT, 0, (LPARAM)This->set_filename); init_explorerbrowser(This); + init_toolbar(This, hwnd); update_layout(This); return TRUE; @@ -495,6 +541,20 @@ static LRESULT on_idcancel(FileDialogImpl *This) return FALSE; } +static LRESULT on_browse_back(FileDialogImpl *This) +{ + TRACE("%p\n", This); + IExplorerBrowser_BrowseToIDList(This->peb, NULL, SBSP_NAVIGATEBACK); + return FALSE; +} + +static LRESULT on_browse_forward(FileDialogImpl *This) +{ + TRACE("%p\n", This); + IExplorerBrowser_BrowseToIDList(This->peb, NULL, SBSP_NAVIGATEFORWARD); + return FALSE; +} + static LRESULT on_command_filetype(FileDialogImpl *This, WPARAM wparam, LPARAM lparam) { if(HIWORD(wparam) == CBN_SELCHANGE) @@ -522,6 +582,8 @@ static LRESULT on_wm_command(FileDialogImpl *This, WPARAM wparam, LPARAM lparam) { case IDOK: return on_idok(This); case IDCANCEL: return on_idcancel(This); + case IDC_NAVBACK: return on_browse_back(This); + case IDC_NAVFORWARD: return on_browse_forward(This); case IDC_FILETYPE: return on_command_filetype(This, wparam, lparam); default: TRACE("Unknown command.\n"); }
1
0
0
0
David Hedberg : comdlg32: We only want to check the low word of wparam.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: b2575dab623acf5527f20d2d863ae5364fe93837 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b2575dab623acf5527f20d2d8…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:27 2011 +0200 comdlg32: We only want to check the low word of wparam. --- dlls/comdlg32/itemdlg.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 92ea665..0d75c33 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -518,7 +518,7 @@ static LRESULT on_command_filetype(FileDialogImpl *This, WPARAM wparam, LPARAM l static LRESULT on_wm_command(FileDialogImpl *This, WPARAM wparam, LPARAM lparam) { - switch(wparam) + switch(LOWORD(wparam)) { case IDOK: return on_idok(This); case IDCANCEL: return on_idcancel(This);
1
0
0
0
David Hedberg : comdlg32: Implement filetype filtering for the item dialog.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: 209069ae46343cdf4ee1589774133d648d65c8c2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=209069ae46343cdf4ee158977…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:26 2011 +0200 comdlg32: Implement filetype filtering for the item dialog. --- dlls/comdlg32/itemdlg.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 41 insertions(+), 2 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 99e41a6..92ea665 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -1746,8 +1746,47 @@ static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface, IShellView *shv, LPCITEMIDLIST pidl) { FileDialogImpl *This = impl_from_ICommDlgBrowser3(iface); - FIXME("Stub: %p (%p, %p)\n", This, shv, pidl); - return S_OK; + IShellItem *psi; + LPWSTR filename; + LPITEMIDLIST parent_pidl; + HRESULT hr; + ULONG attr; + TRACE("%p (%p, %p)\n", This, shv, pidl); + + if(!This->filterspec_count) + return S_OK; + + hr = SHGetIDListFromObject((IUnknown*)shv, &parent_pidl); + if(SUCCEEDED(hr)) + { + LPITEMIDLIST full_pidl = ILCombine(parent_pidl, pidl); + hr = SHCreateItemFromIDList(full_pidl, &IID_IShellItem, (void**)&psi); + ILFree(parent_pidl); + ILFree(full_pidl); + } + if(FAILED(hr)) + { + ERR("Failed to get shellitem (%08x).\n", hr); + return S_OK; + } + + hr = IShellItem_GetAttributes(psi, SFGAO_FOLDER|SFGAO_LINK, &attr); + if(FAILED(hr) || (attr & (SFGAO_FOLDER | SFGAO_LINK))) + { + IShellItem_Release(psi); + return S_OK; + } + + hr = S_OK; + if(SUCCEEDED(IShellItem_GetDisplayName(psi, SIGDN_PARENTRELATIVEPARSING, &filename))) + { + if(!PathMatchSpecW(filename, This->filterspecs[This->filetypeindex].pszSpec)) + hr = S_FALSE; + CoTaskMemFree(filename); + } + + IShellItem_Release(psi); + return hr; } static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1
0
0
0
David Hedberg : comdlg32: Update file name from selection in the item dialog.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: ccfbe722e3cb13d5d43ecc6312e8d2935b07385d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ccfbe722e3cb13d5d43ecc631…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:25 2011 +0200 comdlg32: Update file name from selection in the item dialog. --- dlls/comdlg32/itemdlg.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 97 insertions(+), 1 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 682f01b..99e41a6 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -125,6 +125,76 @@ static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str) return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str); } +static void fill_filename_from_selection(FileDialogImpl *This) +{ + IShellItem *psi; + LPWSTR *names; + HRESULT hr; + UINT item_count, valid_count; + UINT len_total, i; + + if(!This->psia_selection) + return; + + hr = IShellItemArray_GetCount(This->psia_selection, &item_count); + if(FAILED(hr) || !item_count) + return; + + names = HeapAlloc(GetProcessHeap(), 0, item_count*sizeof(LPWSTR)); + + /* Get names of the selected items */ + valid_count = 0; len_total = 0; + for(i = 0; i < item_count; i++) + { + hr = IShellItemArray_GetItemAt(This->psia_selection, i, &psi); + if(SUCCEEDED(hr)) + { + UINT attr; + + hr = IShellItem_GetAttributes(psi, SFGAO_FOLDER, &attr); + if(SUCCEEDED(hr) && (attr & SFGAO_FOLDER)) + continue; /* FIXME: FOS_PICKFOLDERS */ + + hr = IShellItem_GetDisplayName(psi, SIGDN_PARENTRELATIVEPARSING, &names[valid_count]); + if(SUCCEEDED(hr)) + { + len_total += lstrlenW(names[valid_count]) + 3; + valid_count++; + } + IShellItem_Release(psi); + } + } + + if(valid_count == 1) + { + set_file_name(This, names[0]); + CoTaskMemFree(names[0]); + } + else if(valid_count > 1) + { + LPWSTR string = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len_total); + LPWSTR cur_point = string; + + for(i = 0; i < valid_count; i++) + { + LPWSTR file = names[i]; + *cur_point++ = '\"'; + lstrcpyW(cur_point, file); + cur_point += lstrlenW(file); + *cur_point++ = '\"'; + *cur_point++ = ' '; + CoTaskMemFree(file); + } + *(cur_point-1) = '\0'; + + set_file_name(This, string); + HeapFree(GetProcessHeap(), 0, string); + } + + HeapFree(GetProcessHeap(), 0, names); + return; +} + /************************************************************************** * Window related functions. */ @@ -1642,7 +1712,33 @@ static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface, IShellView *shv, ULONG uChange ) { FileDialogImpl *This = impl_from_ICommDlgBrowser3(iface); - FIXME("Stub: %p (%p, %x)\n", This, shv, uChange); + IDataObject *new_selection; + HRESULT hr; + TRACE("%p (%p, %x)\n", This, shv, uChange); + + switch(uChange) + { + case CDBOSC_SELCHANGE: + if(This->psia_selection) + { + IShellItemArray_Release(This->psia_selection); + This->psia_selection = NULL; + } + + hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&new_selection); + if(SUCCEEDED(hr)) + { + hr = SHCreateShellItemArrayFromDataObject(new_selection, &IID_IShellItemArray, + (void**)&This->psia_selection); + if(SUCCEEDED(hr)) + fill_filename_from_selection(This); + + IDataObject_Release(new_selection); + } + break; + default: + TRACE("Unhandled state change\n"); + } return S_OK; }
1
0
0
0
David Hedberg : comdlg32: Implement GetFileName and SetFileName for the item dialog.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: 36bf6e1afe0b4b21ecbc182df4e0419ea566462e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=36bf6e1afe0b4b21ecbc182df…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:24 2011 +0200 comdlg32: Implement GetFileName and SetFileName for the item dialog. --- dlls/comdlg32/itemdlg.c | 70 ++++++++++++++++++++++++++++++++++++++-- dlls/comdlg32/tests/itemdlg.c | 14 +++++--- 2 files changed, 74 insertions(+), 10 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index ef4bb9d..682f01b 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -80,9 +80,52 @@ typedef struct FileDialogImpl { HWND dlg_hwnd; IExplorerBrowser *peb; DWORD ebevents_cookie; + + LPWSTR set_filename; } FileDialogImpl; /************************************************************************** + * Helper functions. + */ +static UINT get_file_name(FileDialogImpl *This, LPWSTR *str) +{ + HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME); + UINT len; + + if(!hwnd_edit) + { + if(This->set_filename) + { + len = lstrlenW(This->set_filename); + *str = CoTaskMemAlloc(sizeof(WCHAR)*(len+1)); + lstrcpyW(*str, This->set_filename); + return len; + } + return FALSE; + } + + len = SendMessageW(hwnd_edit, WM_GETTEXTLENGTH, 0, 0); + *str = CoTaskMemAlloc(sizeof(WCHAR)*(len+1)); + if(!*str) + return FALSE; + + SendMessageW(hwnd_edit, WM_GETTEXT, len+1, (LPARAM)*str); + return len; +} + +static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str) +{ + HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME); + + if(This->set_filename) + LocalFree(This->set_filename); + + This->set_filename = StrDupW(str); + + return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str); +} + +/************************************************************************** * Window related functions. */ static SIZE update_layout(FileDialogImpl *This) @@ -320,6 +363,10 @@ static LRESULT on_wm_initdialog(HWND hwnd, LPARAM lParam) else ShowWindow(hitem, SW_HIDE); + if(This->set_filename && + (hitem = GetDlgItem(This->dlg_hwnd, IDC_FILENAME)) ) + SendMessageW(hitem, WM_SETTEXT, 0, (LPARAM)This->set_filename); + init_explorerbrowser(This); update_layout(This); @@ -533,6 +580,8 @@ static ULONG WINAPI IFileDialog2_fnRelease(IFileDialog2 *iface) if(This->psia_selection) IShellItemArray_Release(This->psia_selection); if(This->psia_results) IShellItemArray_Release(This->psia_results); + LocalFree(This->set_filename); + HeapFree(GetProcessHeap(), 0, This); } @@ -752,15 +801,26 @@ static HRESULT WINAPI IFileDialog2_fnGetCurrentSelection(IFileDialog2 *iface, IS static HRESULT WINAPI IFileDialog2_fnSetFileName(IFileDialog2 *iface, LPCWSTR pszName) { FileDialogImpl *This = impl_from_IFileDialog2(iface); - FIXME("stub - %p (%p)\n", This, pszName); - return E_NOTIMPL; + TRACE("%p (%p)\n", iface, pszName); + + set_file_name(This, pszName); + + return S_OK; } static HRESULT WINAPI IFileDialog2_fnGetFileName(IFileDialog2 *iface, LPWSTR *pszName) { FileDialogImpl *This = impl_from_IFileDialog2(iface); - FIXME("stub - %p (%p)\n", This, pszName); - return E_NOTIMPL; + TRACE("%p (%p)\n", iface, pszName); + + if(!pszName) + return E_INVALIDARG; + + *pszName = NULL; + if(get_file_name(This, pszName)) + return S_OK; + else + return E_FAIL; } static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR pszTitle) @@ -1705,6 +1765,8 @@ static HRESULT FileDialog_constructor(IUnknown *pUnkOuter, REFIID riid, void **p fdimpl->dlg_hwnd = NULL; fdimpl->peb = NULL; + fdimpl->set_filename = NULL; + /* FIXME: The default folder setting should be restored for the * application if it was previously set. */ SHGetDesktopFolder(&psf); diff --git a/dlls/comdlg32/tests/itemdlg.c b/dlls/comdlg32/tests/itemdlg.c index 8f031c2..e14bfaa 100644 --- a/dlls/comdlg32/tests/itemdlg.c +++ b/dlls/comdlg32/tests/itemdlg.c @@ -371,8 +371,6 @@ static void test_basics(void) } /* GetFileName */ - todo_wine - { hr = IFileOpenDialog_GetFileName(pfod, NULL); ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr); filename = (void*)0xdeadbeef; @@ -385,7 +383,6 @@ static void test_basics(void) hr = IFileSaveDialog_GetFileName(pfsd, &filename); ok(hr == E_FAIL, "got 0x%08x.\n", hr); ok(filename == NULL, "got %p\n", filename); - } /* GetFileTypeIndex */ hr = IFileOpenDialog_GetFileTypeIndex(pfod, NULL); @@ -546,14 +543,16 @@ static void test_basics(void) } /* SetFileName */ - todo_wine - { hr = IFileOpenDialog_SetFileName(pfod, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IFileOpenDialog_SetFileName(pfod, null); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IFileOpenDialog_SetFileName(pfod, txt); ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IFileOpenDialog_GetFileName(pfod, &filename); + ok(hr == S_OK, "Got 0x%08x\n", hr); + ok(!lstrcmpW(filename, txt), "Strings do not match.\n"); + CoTaskMemFree(filename); hr = IFileSaveDialog_SetFileName(pfsd, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -561,7 +560,10 @@ static void test_basics(void) ok(hr == S_OK, "got 0x%08x\n", hr); hr = IFileSaveDialog_SetFileName(pfsd, txt); ok(hr == S_OK, "got 0x%08x\n", hr); - } + hr = IFileSaveDialog_GetFileName(pfsd, &filename); + ok(hr == S_OK, "Got 0x%08x\n", hr); + ok(!lstrcmpW(filename, txt), "Strings do not match.\n"); + CoTaskMemFree(filename); /* SetFileNameLabel */ todo_wine
1
0
0
0
David Hedberg : comdlg32: Set explorerbrowser' s site before navigating anywhere.
by Alexandre Julliard
01 Apr '11
01 Apr '11
Module: wine Branch: master Commit: 0a524a0c76bba5364f4c4bfd4ed02ecdf0ad8fa5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0a524a0c76bba5364f4c4bfd4…
Author: David Hedberg <david.hedberg(a)gmail.com> Date: Fri Apr 1 05:52:23 2011 +0200 comdlg32: Set explorerbrowser's site before navigating anywhere. --- dlls/comdlg32/itemdlg.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 35812f2..ef4bb9d 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -281,14 +281,14 @@ static HRESULT init_explorerbrowser(FileDialogImpl *This) IExplorerBrowser_SetFolderSettings(This->peb, &fos); - /* Browse somewhere */ - psi_folder = This->psi_setfolder ? This->psi_setfolder : This->psi_defaultfolder; - IExplorerBrowser_BrowseToObject(This->peb, (IUnknown*)psi_folder, SBSP_DEFBROWSER); - hr = IUnknown_SetSite((IUnknown*)This->peb, (IUnknown*)This); if(FAILED(hr)) ERR("SetSite (ExplorerBrowser) failed.\n"); + /* Browse somewhere */ + psi_folder = This->psi_setfolder ? This->psi_setfolder : This->psi_defaultfolder; + IExplorerBrowser_BrowseToObject(This->peb, (IUnknown*)psi_folder, SBSP_DEFBROWSER); + return S_OK; }
1
0
0
0
← Newer
1
...
88
89
90
91
92
93
94
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Results per page:
10
25
50
100
200