diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-08-10 19:24:24 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-08-10 20:27:48 -0500 |
commit | 3756ae7c8dc60d459511d0b067ebef5efb052746 (patch) | |
tree | 5aa0505d3ab4e4337575597bcad9c6fd641ea78d /src/libs/dutil/WixToolset.DUtil/thmutil.cpp | |
parent | 84e7b6d277e5c3d118e11a45834d420254a758c0 (diff) | |
download | wix-3756ae7c8dc60d459511d0b067ebef5efb052746.tar.gz wix-3756ae7c8dc60d459511d0b067ebef5efb052746.tar.bz2 wix-3756ae7c8dc60d459511d0b067ebef5efb052746.zip |
Use IFileOpenDialog instead of SHBrowseForFolder and GetOpenFileName.
It is the recommended option since Vista and has better long path support.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/thmutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/thmutil.cpp | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp index 52a52a1e..f7f7c5b6 100644 --- a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp | |||
@@ -4992,54 +4992,47 @@ static void OnBrowseDirectory( | |||
4992 | ) | 4992 | ) |
4993 | { | 4993 | { |
4994 | HRESULT hr = S_OK; | 4994 | HRESULT hr = S_OK; |
4995 | WCHAR wzPath[MAX_PATH] = { }; | 4995 | LPWSTR sczPath = NULL; |
4996 | BROWSEINFOW browseInfo = { }; | 4996 | THEME_CONTROL* pTargetControl = NULL; |
4997 | PIDLIST_ABSOLUTE pidl = NULL; | 4997 | BOOL fSetVariable = NULL != pTheme->pfnSetStringVariable; |
4998 | 4998 | ||
4999 | browseInfo.hwndOwner = pTheme->hwndParent; | 4999 | hr = WnduShowOpenFolderDialog(pTheme->hwndParent, TRUE, pTheme->sczCaption, &sczPath); |
5000 | browseInfo.pszDisplayName = wzPath; | 5000 | if (HRESULT_FROM_WIN32(ERROR_CANCELLED) == hr) |
5001 | browseInfo.lpszTitle = pTheme->sczCaption; | ||
5002 | browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; | ||
5003 | pidl = ::SHBrowseForFolderW(&browseInfo); | ||
5004 | if (pidl && ::SHGetPathFromIDListW(pidl, wzPath)) | ||
5005 | { | 5001 | { |
5006 | // Since editbox changes aren't immediately saved off, we have to treat them differently. | 5002 | ExitFunction(); |
5007 | THEME_CONTROL* pTargetControl = NULL; | 5003 | } |
5008 | BOOL fSetVariable = NULL != pTheme->pfnSetStringVariable; | 5004 | ThmExitOnFailure(hr, "Failed to prompt user for directory."); |
5009 | |||
5010 | for (DWORD i = 0; i < pTheme->cControls; ++i) | ||
5011 | { | ||
5012 | THEME_CONTROL* pControl = pTheme->rgControls + i; | ||
5013 | |||
5014 | if ((!pControl->wPageId || pControl->wPageId == pTheme->dwCurrentPageId) && | ||
5015 | CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pControl->sczName, -1, pAction->BrowseDirectory.sczVariableName, -1)) | ||
5016 | { | ||
5017 | pTargetControl = pControl; | ||
5018 | break; | ||
5019 | } | ||
5020 | } | ||
5021 | 5005 | ||
5022 | if (pTargetControl && !pTargetControl->fDisableAutomaticFunctionality && (!fSetVariable || THEME_CONTROL_TYPE_EDITBOX == pTargetControl->type)) | 5006 | for (DWORD i = 0; i < pTheme->cControls; ++i) |
5023 | { | 5007 | { |
5024 | fSetVariable = FALSE; | 5008 | THEME_CONTROL* pControl = pTheme->rgControls + i; |
5025 | hr = ThemeSetTextControl(pTargetControl, wzPath); | ||
5026 | ThmExitOnFailure(hr, "Failed to set text on control: %ls", pTargetControl->sczName); | ||
5027 | } | ||
5028 | 5009 | ||
5029 | if (fSetVariable) | 5010 | if ((!pControl->wPageId || pControl->wPageId == pTheme->dwCurrentPageId) && |
5011 | CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pControl->sczName, -1, pAction->BrowseDirectory.sczVariableName, -1)) | ||
5030 | { | 5012 | { |
5031 | hr = pTheme->pfnSetStringVariable(pAction->BrowseDirectory.sczVariableName, wzPath, FALSE, pTheme->pvVariableContext); | 5013 | pTargetControl = pControl; |
5032 | ThmExitOnFailure(hr, "Failed to set variable: %ls", pAction->BrowseDirectory.sczVariableName); | 5014 | break; |
5033 | } | 5015 | } |
5016 | } | ||
5034 | 5017 | ||
5035 | ThemeShowPageEx(pTheme, pTheme->dwCurrentPageId, SW_SHOW, THEME_SHOW_PAGE_REASON_REFRESH); | 5018 | // Since editbox changes aren't immediately saved off, we have to treat them differently. |
5019 | if (pTargetControl && !pTargetControl->fDisableAutomaticFunctionality && (!fSetVariable || THEME_CONTROL_TYPE_EDITBOX == pTargetControl->type)) | ||
5020 | { | ||
5021 | fSetVariable = FALSE; | ||
5022 | hr = ThemeSetTextControl(pTargetControl, sczPath); | ||
5023 | ThmExitOnFailure(hr, "Failed to set text on control: %ls", pTargetControl->sczName); | ||
5036 | } | 5024 | } |
5037 | 5025 | ||
5038 | LExit: | 5026 | if (fSetVariable) |
5039 | if (pidl) | ||
5040 | { | 5027 | { |
5041 | ::CoTaskMemFree(pidl); | 5028 | hr = pTheme->pfnSetStringVariable(pAction->BrowseDirectory.sczVariableName, sczPath, FALSE, pTheme->pvVariableContext); |
5029 | ThmExitOnFailure(hr, "Failed to set variable: %ls", pAction->BrowseDirectory.sczVariableName); | ||
5042 | } | 5030 | } |
5031 | |||
5032 | ThemeShowPageEx(pTheme, pTheme->dwCurrentPageId, SW_SHOW, THEME_SHOW_PAGE_REASON_REFRESH); | ||
5033 | |||
5034 | LExit: | ||
5035 | ReleaseStr(sczPath); | ||
5043 | } | 5036 | } |
5044 | 5037 | ||
5045 | static BOOL OnButtonClicked( | 5038 | static BOOL OnButtonClicked( |