Commit 426984dd authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to

be able to browse shell namespace extensions.
parent d8c10047
......@@ -511,6 +511,27 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
return ret;
}
/******************************************************************************
* COMDLG32_GetDisplayNameOf [internal]
*
* Helper function to get the display name for a pidl.
*/
static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {
LPSHELLFOLDER psfDesktop;
STRRET strret;
if (FAILED(SHGetDesktopFolder(&psfDesktop)))
return FALSE;
if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {
IShellFolder_Release(psfDesktop);
return FALSE;
}
IShellFolder_Release(psfDesktop);
return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
}
/***********************************************************************
* ArrangeCtrlPositions [internal]
*
......@@ -841,7 +862,7 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
return -1;
/* get path and filenames */
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);
n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
TRACE("path >%s< filespec >%s< %d files\n",
......@@ -925,6 +946,7 @@ HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
WCHAR lpstrPath[MAX_PATH];
if(!fodInfos) return -1;
switch(uMsg)
......@@ -934,22 +956,16 @@ HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam
case CDM_GETFOLDERPATH:
TRACE("CDM_GETFOLDERPATH:\n");
if( fodInfos->unicode )
{
WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam;
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufW)
lstrcpynW(bufW,lpstrPath,(int)wParam);
return strlenW(lpstrPath);
}
else
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
if (lParam)
{
char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam;
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufA)
lstrcpynA(bufA,lpstrPath,(int)wParam);
return strlen(lpstrPath);
}
if (fodInfos->unicode)
lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
else
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
(LPSTR)lParam, (int)wParam, NULL, NULL);
}
return strlenW(lpstrPath);
case CDM_GETSPEC:
return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
......@@ -1597,7 +1613,7 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
ofn->lpstrFile[0] = '\0';
}
SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
......@@ -1742,14 +1758,10 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
*/
/* Get the current directory name */
if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
{
/* we are in a special folder, default to desktop */
if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
{
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
PathAddBackslashW(lpstrPathAndFile);
......
......@@ -140,11 +140,25 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags)
static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
{
char lpstrPath[MAX_PATH];
if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
SetCurrentDirectoryA(lpstrPath);
TRACE("new current folder %s\n", lpstrPath);
LPSHELLFOLDER psfDesktop;
STRRET strret;
HRESULT res;
res = SHGetDesktopFolder(&psfDesktop);
if (FAILED(res))
return;
res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
SHGDN_FORPARSING, &strret);
if (SUCCEEDED(res)) {
WCHAR wszCurrentDir[MAX_PATH];
res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
if (SUCCEEDED(res))
SetCurrentDirectoryW(wszCurrentDir);
}
IShellFolder_Release(psfDesktop);
}
/* copied from shell32 to avoid linking to it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment