Browse to the directory if a directory name is typed into the edit box

of a file dialog and the confirmation button (or Enter key) is hit.
Return any file name in the edit box if OFN_NOVALIDATE is set and
OFN_FILEMUSTEXIST is not, even if that file name includes a path name
or is the name of a folder.
This commit is contained in:
Troy Rollo 2005-08-10 09:50:29 +00:00 committed by Alexandre Julliard
parent bea21461ec
commit b1d96713ed
1 changed files with 54 additions and 47 deletions

View File

@ -1711,8 +1711,9 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
*
* If the function succeeds, the return value is nonzero.
*/
#define ONOPEN_OPEN 1
#define ONOPEN_SEARCH 2
#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];
@ -1739,15 +1740,15 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
TRACE("hwnd=%p\n", hwnd);
if(BrowseSelectedFolder(hwnd))
return FALSE;
/* get the files from the edit control */
nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0');
/* try if the user selected a folder in the shellview */
if(nFileCount == 0)
{
BrowseSelectedFolder(hwnd);
return FALSE;
}
if(nFileCount > 1)
{
@ -1808,7 +1809,12 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
lpstrPathAndFile: cleaned up path
*/
if (nFileCount &&
(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
!(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
nOpenAction = ONOPEN_OPEN;
else
nOpenAction = ONOPEN_BROWSE;
/* don't apply any checks with OFN_NOVALIDATE */
{
@ -1842,7 +1848,8 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
*p = 0;
lpszTemp = lpszTemp + strlenW(lpwstrTemp);
if(*lpszTemp==0)
/* 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 */
@ -1941,7 +1948,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
int iPos;
LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
DWORD len;
IPersistFolder2 * ppf2;
/* replace the current filter */
if(fodInfos->ShellInfos.lpstrCurrentFilter)
@ -1953,7 +1959,12 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
/* set the filter cb to the extension when possible */
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);
}
/* fall through */
case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
TRACE("ONOPEN_BROWSE\n");
{
IPersistFolder2 * ppf2;
if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
{
LPITEMIDLIST pidlCurrent;
@ -1963,11 +1974,10 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
{
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
}
else
else if( nOpenAction == ONOPEN_SEARCH )
{
IShellView_Refresh(fodInfos->Shell.FOIShellView);
}
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
COMDLG32_SHFree(pidlCurrent);
}
}
@ -1985,10 +1995,8 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
/* Attach the file extension with file name*/
if(!PathIsDirectoryW(lpstrPathAndFile))
{
if((ext = PathFindExtensionW(lpstrPathAndFile)) == NULL)
ext = PathFindExtensionW(lpstrPathAndFile);
if (! *ext)
{
/* if no extension is specified with file name, then */
/* attach the extension from file filter or default one */
@ -2028,7 +2036,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
else
fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT;
}
}
/* In Save dialog: check if the file already exists */
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG