aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-10-27 15:29:19 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-11-01 16:34:09 -0500
commitdce1c97c7d3e76c18e4f80d4ffe288d2933a74bc (patch)
tree68dc0653ee1a6fe962d82dac2159c8ab00a95808 /src/ext/Bal
parentbad2e93524f376cfeb76d5231d4b08510bdad033 (diff)
downloadwix-dce1c97c7d3e76c18e4f80d4ffe288d2933a74bc.tar.gz
wix-dce1c97c7d3e76c18e4f80d4ffe288d2933a74bc.tar.bz2
wix-dce1c97c7d3e76c18e4f80d4ffe288d2933a74bc.zip
Make thmutil automatically load controls during window creation.
Add control loaded event.
Diffstat (limited to 'src/ext/Bal')
-rw-r--r--src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp188
1 files changed, 114 insertions, 74 deletions
diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
index 2283880c..5546b74f 100644
--- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
@@ -2389,6 +2389,11 @@ private:
2389 hr = ThemeRegisterVariableCallbacks(m_pTheme, EvaluateVariableConditionCallback, FormatVariableStringCallback, GetVariableNumericCallback, SetVariableNumericCallback, GetVariableStringCallback, SetVariableStringCallback, NULL); 2389 hr = ThemeRegisterVariableCallbacks(m_pTheme, EvaluateVariableConditionCallback, FormatVariableStringCallback, GetVariableNumericCallback, SetVariableNumericCallback, GetVariableStringCallback, SetVariableStringCallback, NULL);
2390 BalExitOnFailure(hr, "Failed to register variable theme callbacks."); 2390 BalExitOnFailure(hr, "Failed to register variable theme callbacks.");
2391 2391
2392 C_ASSERT(COUNT_WIXSTDBA_PAGE == countof(vrgwzPageNames));
2393 C_ASSERT(countof(m_rgdwPageIds) == countof(vrgwzPageNames));
2394
2395 ThemeGetPageIds(m_pTheme, vrgwzPageNames, m_rgdwPageIds, countof(m_rgdwPageIds));
2396
2392 hr = ThemeLocalize(m_pTheme, m_pWixLoc); 2397 hr = ThemeLocalize(m_pTheme, m_pWixLoc);
2393 BalExitOnFailure(hr, "Failed to localize theme: %ls", sczThemePath); 2398 BalExitOnFailure(hr, "Failed to localize theme: %ls", sczThemePath);
2394 2399
@@ -2697,6 +2702,8 @@ private:
2697 hr = ThemeCreateParentWindow(m_pTheme, 0, wc.lpszClassName, m_pTheme->sczCaption, dwWindowStyle, x, y, HWND_DESKTOP, m_hModule, this, THEME_WINDOW_INITIAL_POSITION_CENTER_MONITOR_FROM_COORDINATES, &m_hWnd); 2702 hr = ThemeCreateParentWindow(m_pTheme, 0, wc.lpszClassName, m_pTheme->sczCaption, dwWindowStyle, x, y, HWND_DESKTOP, m_hModule, this, THEME_WINDOW_INITIAL_POSITION_CENTER_MONITOR_FROM_COORDINATES, &m_hWnd);
2698 ExitOnFailure(hr, "Failed to create window."); 2703 ExitOnFailure(hr, "Failed to create window.");
2699 2704
2705 OnThemeLoaded();
2706
2700 hr = S_OK; 2707 hr = S_OK;
2701 2708
2702 LExit: 2709 LExit:
@@ -2831,16 +2838,12 @@ private:
2831 return lres; 2838 return lres;
2832 } 2839 }
2833 2840
2834 case WM_CREATE:
2835 if (!pBA->OnCreate(hWnd))
2836 {
2837 return -1;
2838 }
2839 break;
2840
2841 case WM_THMUTIL_LOADING_CONTROL: 2841 case WM_THMUTIL_LOADING_CONTROL:
2842 return pBA->OnThemeLoadingControl(reinterpret_cast<THEME_LOADINGCONTROL_ARGS*>(wParam), reinterpret_cast<THEME_LOADINGCONTROL_RESULTS*>(lParam)); 2842 return pBA->OnThemeLoadingControl(reinterpret_cast<THEME_LOADINGCONTROL_ARGS*>(wParam), reinterpret_cast<THEME_LOADINGCONTROL_RESULTS*>(lParam));
2843 2843
2844 case WM_THMUTIL_LOADED_CONTROL:
2845 return pBA->OnThemeLoadedControl(reinterpret_cast<THEME_LOADEDCONTROL_ARGS*>(wParam), reinterpret_cast<THEME_LOADEDCONTROL_RESULTS*>(lParam));
2846
2844 case WM_QUERYENDSESSION: 2847 case WM_QUERYENDSESSION:
2845 fCancel = true; 2848 fCancel = true;
2846 pBA->OnSystemShutdown(static_cast<DWORD>(lParam), &fCancel); 2849 pBA->OnSystemShutdown(static_cast<DWORD>(lParam), &fCancel);
@@ -2896,74 +2899,14 @@ private:
2896 2899
2897 2900
2898 // 2901 //
2899 // OnCreate - finishes loading the theme. 2902 // OnThemeLoaded - finishes loading the theme.
2900 // 2903 //
2901 BOOL OnCreate( 2904 BOOL OnThemeLoaded()
2902 __in HWND /*hWnd*/
2903 )
2904 { 2905 {
2905 HRESULT hr = S_OK; 2906 HRESULT hr = S_OK;
2906 LPWSTR sczLicenseFormatted = NULL;
2907 LPWSTR sczLicensePath = NULL;
2908 LPWSTR sczLicenseDirectory = NULL;
2909 LPWSTR sczLicenseFilename = NULL;
2910 BA_FUNCTIONS_ONTHEMELOADED_ARGS themeLoadedArgs = { }; 2907 BA_FUNCTIONS_ONTHEMELOADED_ARGS themeLoadedArgs = { };
2911 BA_FUNCTIONS_ONTHEMELOADED_RESULTS themeLoadedResults = { }; 2908 BA_FUNCTIONS_ONTHEMELOADED_RESULTS themeLoadedResults = { };
2912 2909
2913 hr = ThemeLoadControls(m_pTheme);
2914 BalExitOnFailure(hr, "Failed to load theme controls.");
2915
2916 C_ASSERT(COUNT_WIXSTDBA_PAGE == countof(vrgwzPageNames));
2917 C_ASSERT(countof(m_rgdwPageIds) == countof(vrgwzPageNames));
2918
2919 ThemeGetPageIds(m_pTheme, vrgwzPageNames, m_rgdwPageIds, countof(m_rgdwPageIds));
2920
2921 // Load the RTF EULA control with text if the control exists.
2922 if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_EULA_RICHEDIT))
2923 {
2924 hr = (m_sczLicenseFile && *m_sczLicenseFile) ? S_OK : E_INVALIDDATA;
2925 if (SUCCEEDED(hr))
2926 {
2927 hr = StrAllocString(&sczLicenseFormatted, m_sczLicenseFile, 0);
2928 if (SUCCEEDED(hr))
2929 {
2930 hr = LocLocalizeString(m_pWixLoc, &sczLicenseFormatted);
2931 if (SUCCEEDED(hr))
2932 {
2933 // Assume there is no hidden variables to be formatted
2934 // so don't worry about securely freeing it.
2935 hr = BalFormatString(sczLicenseFormatted, &sczLicenseFormatted);
2936 if (SUCCEEDED(hr))
2937 {
2938 hr = PathRelativeToModule(&sczLicensePath, sczLicenseFormatted, m_hModule);
2939 if (SUCCEEDED(hr))
2940 {
2941 hr = PathGetDirectory(sczLicensePath, &sczLicenseDirectory);
2942 if (SUCCEEDED(hr))
2943 {
2944 hr = StrAllocString(&sczLicenseFilename, PathFile(sczLicenseFormatted), 0);
2945 if (SUCCEEDED(hr))
2946 {
2947 hr = LocProbeForFile(sczLicenseDirectory, sczLicenseFilename, m_sczLanguage, &sczLicensePath);
2948 if (SUCCEEDED(hr))
2949 {
2950 hr = ThemeLoadRichEditFromFile(m_pTheme, WIXSTDBA_CONTROL_EULA_RICHEDIT, sczLicensePath, m_hModule);
2951 }
2952 }
2953 }
2954 }
2955 }
2956 }
2957 }
2958 }
2959
2960 if (FAILED(hr))
2961 {
2962 BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load file into license richedit control from path '%ls' manifest value: %ls", sczLicensePath, m_sczLicenseFile);
2963 hr = S_OK;
2964 }
2965 }
2966
2967 if (m_pfnBAFunctionsProc) 2910 if (m_pfnBAFunctionsProc)
2968 { 2911 {
2969 themeLoadedArgs.cbSize = sizeof(themeLoadedArgs); 2912 themeLoadedArgs.cbSize = sizeof(themeLoadedArgs);
@@ -2975,11 +2918,6 @@ private:
2975 } 2918 }
2976 2919
2977 LExit: 2920 LExit:
2978 ReleaseStr(sczLicenseFilename);
2979 ReleaseStr(sczLicenseDirectory);
2980 ReleaseStr(sczLicensePath);
2981 ReleaseStr(sczLicenseFormatted);
2982
2983 return SUCCEEDED(hr); 2921 return SUCCEEDED(hr);
2984 } 2922 }
2985 2923
@@ -3034,6 +2972,108 @@ private:
3034 return fProcessed || FAILED(hr); 2972 return fProcessed || FAILED(hr);
3035 } 2973 }
3036 2974
2975 BOOL OnThemeLoadedControl(
2976 __in const THEME_LOADEDCONTROL_ARGS* pArgs,
2977 __in THEME_LOADEDCONTROL_RESULTS* pResults
2978 )
2979 {
2980 HRESULT hr = S_OK;
2981 BOOL fProcessed = FALSE;
2982 BA_FUNCTIONS_ONTHEMECONTROLLOADED_ARGS themeControlLoadedArgs = { };
2983 BA_FUNCTIONS_ONTHEMECONTROLLOADED_RESULTS themeControlLoadedResults = { };
2984
2985 if (WIXSTDBA_CONTROL_EULA_RICHEDIT == pArgs->pThemeControl->wId)
2986 {
2987 // Best effort to load the RTF EULA control with text.
2988 OnLoadedEulaRtfControl(pArgs->pThemeControl);
2989 fProcessed = TRUE;
2990 ExitFunction();
2991 }
2992
2993 if (m_pfnBAFunctionsProc)
2994 {
2995 themeControlLoadedArgs.cbSize = sizeof(themeControlLoadedArgs);
2996 themeControlLoadedArgs.wzName = pArgs->pThemeControl->sczName;
2997 themeControlLoadedArgs.wId = pArgs->pThemeControl->wId;
2998 themeControlLoadedArgs.hWnd = pArgs->pThemeControl->hWnd;
2999
3000 themeControlLoadedResults.cbSize = sizeof(themeControlLoadedResults);
3001
3002 hr = m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADED, &themeControlLoadedArgs, &themeControlLoadedResults, m_pvBAFunctionsProcContext);
3003
3004 if (E_NOTIMPL == hr)
3005 {
3006 hr = S_OK;
3007 }
3008 else
3009 {
3010 BalExitOnFailure(hr, "BAFunctions OnThemeControlLoaded failed.");
3011
3012 if (themeControlLoadedResults.fProcessed)
3013 {
3014 fProcessed = TRUE;
3015 }
3016 }
3017 }
3018
3019 LExit:
3020 pResults->hr = hr;
3021 return fProcessed || FAILED(hr);
3022 }
3023
3024 HRESULT OnLoadedEulaRtfControl(
3025 const THEME_CONTROL* pThemeControl
3026 )
3027 {
3028 HRESULT hr = S_OK;
3029 LPWSTR sczLicenseFormatted = NULL;
3030 LPWSTR sczLicensePath = NULL;
3031 LPWSTR sczLicenseDirectory = NULL;
3032 LPWSTR sczLicenseFilename = NULL;
3033
3034 if (!m_sczLicenseFile || !*m_sczLicenseFile)
3035 {
3036 ExitWithRootFailure(hr, E_INVALIDDATA, "No license file in manifest.");
3037 }
3038
3039 hr = StrAllocString(&sczLicenseFormatted, m_sczLicenseFile, 0);
3040 ExitOnFailure(hr, "Failed to copy manifest license file.");
3041
3042 hr = LocLocalizeString(m_pWixLoc, &sczLicenseFormatted);
3043 ExitOnFailure(hr, "Failed to localize manifest license file.");
3044
3045 hr = BalFormatString(sczLicenseFormatted, &sczLicenseFormatted);
3046 ExitOnFailure(hr, "Failed to expand localized manifest license file.");
3047
3048 hr = PathRelativeToModule(&sczLicensePath, sczLicenseFormatted, m_hModule);
3049 ExitOnFailure(hr, "Failed to get relative path for license file.");
3050
3051 hr = PathGetDirectory(sczLicensePath, &sczLicenseDirectory);
3052 ExitOnFailure(hr, "Failed to get license file directory.");
3053
3054 hr = StrAllocString(&sczLicenseFilename, PathFile(sczLicenseFormatted), 0);
3055 ExitOnFailure(hr, "Failed to copy license file name.");
3056
3057 hr = LocProbeForFile(sczLicenseDirectory, sczLicenseFilename, m_sczLanguage, &sczLicensePath);
3058 ExitOnFailure(hr, "Failed to probe for localized license file.");
3059
3060 hr = ThemeLoadRichEditFromFile(m_pTheme, pThemeControl->wId, sczLicensePath, m_hModule);
3061 ExitOnFailure(hr, "Failed to load license file into richedit control.");
3062
3063 LExit:
3064 if (FAILED(hr))
3065 {
3066 BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load file into license richedit control from path '%ls' manifest value: %ls", sczLicensePath, m_sczLicenseFile);
3067 }
3068
3069 ReleaseStr(sczLicenseFilename);
3070 ReleaseStr(sczLicenseDirectory);
3071 ReleaseStr(sczLicensePath);
3072 ReleaseStr(sczLicenseFormatted);
3073
3074 return hr;
3075 }
3076
3037 3077
3038 // 3078 //
3039 // OnShowFailure - display the failure page. 3079 // OnShowFailure - display the failure page.