aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-07-24 14:09:38 -0500
committerBob Arnson <github@bobs.org>2022-07-25 13:04:12 -0400
commit2e327df0b7c785a6cad36f6b3bf79ba8becf9000 (patch)
tree4c39c81fdc13571d90b4d19e44e43f120e4a3bfe
parentf1c74f3f60a0b1845806a2c6f7082692a8f37b7e (diff)
downloadwix-2e327df0b7c785a6cad36f6b3bf79ba8becf9000.tar.gz
wix-2e327df0b7c785a6cad36f6b3bf79ba8becf9000.tar.bz2
wix-2e327df0b7c785a6cad36f6b3bf79ba8becf9000.zip
Use radio buttons in FilesInUse task dialog.
-rw-r--r--src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
index bd0f5a3b..2ef829d7 100644
--- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
@@ -1044,7 +1044,7 @@ public: // IBootstrapperApplication
1044 __in int nRecommendation, 1044 __in int nRecommendation,
1045 __in BOOTSTRAPPER_FILES_IN_USE_TYPE source, 1045 __in BOOTSTRAPPER_FILES_IN_USE_TYPE source,
1046 __inout int* pResult 1046 __inout int* pResult
1047 ) 1047 )
1048 { 1048 {
1049 1049
1050 if (!m_fShowingInternalUiThisPackage && !m_fPrereq && wzPackageId && *wzPackageId) 1050 if (!m_fShowingInternalUiThisPackage && !m_fPrereq && wzPackageId && *wzPackageId)
@@ -2217,14 +2217,14 @@ private: // privates
2217 __in DWORD cFiles, 2217 __in DWORD cFiles,
2218 __in_ecount_z(cFiles) LPCWSTR* rgwzFiles, 2218 __in_ecount_z(cFiles) LPCWSTR* rgwzFiles,
2219 __in BOOTSTRAPPER_FILES_IN_USE_TYPE /*source*/ 2219 __in BOOTSTRAPPER_FILES_IN_USE_TYPE /*source*/
2220 ) 2220 )
2221 { 2221 {
2222 HRESULT hr = S_OK; 2222 HRESULT hr = S_OK;
2223 LPWSTR sczFilesInUse = NULL; 2223 LPWSTR sczFilesInUse = NULL;
2224 DWORD_PTR cchLen = 0; 2224 DWORD_PTR cchLen = 0;
2225 int nResult = IDERROR; 2225 int nResult = IDERROR;
2226 2226
2227 // If the user has choosen to ignore on a previously displayed "files in use" page, 2227 // If the user has chosen to ignore on a previously displayed "files in use" page,
2228 // we will return the same result for other cases. No need to display the page again. 2228 // we will return the same result for other cases. No need to display the page again.
2229 if (IDIGNORE == m_nLastFilesInUseResult) 2229 if (IDIGNORE == m_nLastFilesInUseResult)
2230 { 2230 {
@@ -2232,26 +2232,20 @@ private: // privates
2232 } 2232 }
2233 else if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) // Only show files in use when using full display mode. 2233 else if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) // Only show files in use when using full display mode.
2234 { 2234 {
2235 // Show applications using the files. 2235 // See https://docs.microsoft.com/en-us/windows/win32/msi/sending-messages-to-windows-installer-using-msiprocessmessage for details.
2236 if (cFiles > 0) 2236 for (DWORD i = 1; i < cFiles; i += 2)
2237 { 2237 {
2238 // See https://msdn.microsoft.com/en-us/library/aa371614%28v=vs.85%29.aspx for details. 2238 hr = ::StringCchLengthW(rgwzFiles[i], STRSAFE_MAX_CCH, reinterpret_cast<UINT_PTR*>(&cchLen));
2239 for (DWORD i = 1; i < cFiles; i += 2) 2239 BalExitOnFailure(hr, "Failed to calculate length of string.");
2240 {
2241 hr = ::StringCchLengthW(rgwzFiles[i], STRSAFE_MAX_CCH, reinterpret_cast<UINT_PTR*>(&cchLen));
2242 BalExitOnFailure(hr, "Failed to calculate length of string");
2243
2244 if (cchLen > 0)
2245 {
2246 hr = StrAllocConcat(&sczFilesInUse, rgwzFiles[i], 0);
2247 BalExitOnFailure(hr, "Failed to concat files in use");
2248 2240
2249 hr = StrAllocConcat(&sczFilesInUse, L"\r\n", 2); 2241 if (cchLen)
2250 BalExitOnFailure(hr, "Failed to concat files in use"); 2242 {
2251 } 2243 hr = StrAllocConcatFormatted(&sczFilesInUse, L"%ls\r\n", rgwzFiles[i]);
2244 BalExitOnFailure(hr, "Failed to concat files in use.");
2252 } 2245 }
2253 } 2246 }
2254 2247
2248 // Show applications using the files.
2255 hr = ShowFilesInUseDialog(sczFilesInUse, &nResult); 2249 hr = ShowFilesInUseDialog(sczFilesInUse, &nResult);
2256 ExitOnFailure(hr, "Failed to show files-in-use task dialog."); 2250 ExitOnFailure(hr, "Failed to show files-in-use task dialog.");
2257 } 2251 }
@@ -2275,7 +2269,7 @@ private: // privates
2275 int ShowFilesInUseDialog( 2269 int ShowFilesInUseDialog(
2276 __in_z_opt LPCWSTR sczFilesInUse, 2270 __in_z_opt LPCWSTR sczFilesInUse,
2277 __out int* pnResult 2271 __out int* pnResult
2278 ) 2272 )
2279 { 2273 {
2280 HRESULT hr = S_OK; 2274 HRESULT hr = S_OK;
2281 TASKDIALOGCONFIG config = { }; 2275 TASKDIALOGCONFIG config = { };
@@ -2284,6 +2278,8 @@ private: // privates
2284 LPWSTR sczCloseRadioButton = NULL; 2278 LPWSTR sczCloseRadioButton = NULL;
2285 LPWSTR sczDontCloseRadioButton = NULL; 2279 LPWSTR sczDontCloseRadioButton = NULL;
2286 LOC_STRING* pLocString = NULL; 2280 LOC_STRING* pLocString = NULL;
2281 int nButton = 0;
2282 int nRadioButton = 0;
2287 2283
2288 // Get the loc strings for the files-in-use task dialog text. 2284 // Get the loc strings for the files-in-use task dialog text.
2289 hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseTitle)", &pLocString); 2285 hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseTitle)", &pLocString);
@@ -2310,24 +2306,33 @@ private: // privates
2310 hr = StrAllocString(&sczDontCloseRadioButton, pLocString->wzText, 0); 2306 hr = StrAllocString(&sczDontCloseRadioButton, pLocString->wzText, 0);
2311 ExitOnFailure(hr, "Failed to copy FilesInUseDontCloseRadioButton loc string."); 2307 ExitOnFailure(hr, "Failed to copy FilesInUseDontCloseRadioButton loc string.");
2312 2308
2313 const TASKDIALOG_BUTTON buttons[] = { 2309 const TASKDIALOG_BUTTON rgRadioButtons[] = {
2314 { IDOK, sczCloseRadioButton }, 2310 { IDOK, sczCloseRadioButton },
2315 { IDIGNORE, sczDontCloseRadioButton }, 2311 { IDIGNORE, sczDontCloseRadioButton },
2316 }; 2312 };
2317 2313
2318 config.cbSize = sizeof(config); 2314 config.cbSize = sizeof(config);
2315 config.hwndParent = m_hWnd;
2319 config.hInstance = m_hModule; 2316 config.hInstance = m_hModule;
2320 config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_USE_COMMAND_LINKS | TDF_SIZE_TO_CONTENT; 2317 config.dwFlags = TDF_SIZE_TO_CONTENT | TDF_POSITION_RELATIVE_TO_WINDOW;
2321 config.dwCommonButtons = TDCBF_CANCEL_BUTTON; 2318 config.dwCommonButtons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
2322 config.pszWindowTitle = sczTitle; 2319 config.pszWindowTitle = sczTitle;
2323 config.pszMainInstruction = sczLabel; 2320 config.pszMainInstruction = sczLabel;
2324 config.pszContent = sczFilesInUse ? sczFilesInUse : L""; 2321 config.pszContent = sczFilesInUse ? sczFilesInUse : L"";
2325 config.pButtons = buttons; 2322 config.nDefaultButton = IDOK;
2326 config.cButtons = 2; 2323 config.pRadioButtons = rgRadioButtons;
2324 config.cRadioButtons = countof(rgRadioButtons);
2325 config.nDefaultRadioButton = IDOK;
2327 2326
2328 hr = TaskDialogIndirect(&config, pnResult, NULL, NULL); 2327 hr = ::TaskDialogIndirect(&config, &nButton, &nRadioButton, NULL);
2329 ExitOnFailure(hr, "Failed to show files-in-use task dialog."); 2328 ExitOnFailure(hr, "Failed to show files-in-use task dialog.");
2330 2329
2330 *pnResult = IDOK == nButton ? nRadioButton : nButton;
2331
2332#ifdef DEBUG
2333 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: FilesInUse task dialog result: button - %d, radio button - %d, result - %d", nButton, nRadioButton, *pnResult);
2334#endif
2335
2331 LExit: 2336 LExit:
2332 return hr; 2337 return hr;
2333 } 2338 }