From dce1c97c7d3e76c18e4f80d4ffe288d2933a74bc Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 27 Oct 2021 15:29:19 -0500 Subject: Make thmutil automatically load controls during window creation. Add control loaded event. --- src/api/burn/balutil/inc/BAFunctions.h | 15 +++++++++++++++ src/api/burn/balutil/inc/BalBaseBAFunctions.h | 10 ++++++++++ src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h | 12 ++++++++++++ src/api/burn/balutil/inc/IBAFunctions.h | 9 +++++++++ src/api/burn/balutil/inc/balutil.h | 2 ++ src/api/burn/bextutil/inc/bextutil.h | 2 ++ 6 files changed, 50 insertions(+) (limited to 'src/api') diff --git a/src/api/burn/balutil/inc/BAFunctions.h b/src/api/burn/balutil/inc/BAFunctions.h index ab6ea4d7..0eda95a1 100644 --- a/src/api/burn/balutil/inc/BAFunctions.h +++ b/src/api/burn/balutil/inc/BAFunctions.h @@ -88,6 +88,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADING, BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMCOMMAND, BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMNOTIFY, + BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADED, }; typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_PROC)( @@ -115,6 +116,20 @@ struct BA_FUNCTIONS_CREATE_RESULTS LPVOID pvBAFunctionsProcContext; }; +struct BA_FUNCTIONS_ONTHEMECONTROLLOADED_ARGS +{ + DWORD cbSize; + LPCWSTR wzName; + WORD wId; + HWND hWnd; +}; + +struct BA_FUNCTIONS_ONTHEMECONTROLLOADED_RESULTS +{ + DWORD cbSize; + BOOL fProcessed; +}; + struct BA_FUNCTIONS_ONTHEMECONTROLLOADING_ARGS { DWORD cbSize; diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h index f6c33f58..d97df350 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -874,6 +874,16 @@ public: // IBAFunctions return S_OK; } + virtual STDMETHODIMP OnThemeControlLoaded( + __in LPCWSTR /*wzName*/, + __in WORD /*wId*/, + __in HWND /*hWnd*/, + __inout BOOL* /*pfProcessed*/ + ) + { + return S_OK; + } + protected: CBalBaseBAFunctions( __in HMODULE hModule, diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h index 1d51c5b6..2af231e8 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h @@ -51,6 +51,15 @@ static HRESULT BalBaseBAFunctionsProcOnThemeControlWmNotify( return pBAFunctions->OnThemeControlWmNotify(pArgs->lParam, pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed, &pResults->lResult); } +static HRESULT BalBaseBAFunctionsProcOnThemeControlLoaded( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMECONTROLLOADED_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMECONTROLLOADED_RESULTS* pResults + ) +{ + return pBAFunctions->OnThemeControlLoaded(pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed); +} + /******************************************************************* BalBaseBAFunctionsProc - requires pvContext to be of type IBAFunctions. Provides a default mapping between the message based BAFunctions interface and @@ -161,6 +170,9 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMNOTIFY: hr = BalBaseBAFunctionsProcOnThemeControlWmNotify(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADED: + hr = BalBaseBAFunctionsProcOnThemeControlLoaded(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; } } diff --git a/src/api/burn/balutil/inc/IBAFunctions.h b/src/api/burn/balutil/inc/IBAFunctions.h index 63395e1e..2e71608d 100644 --- a/src/api/burn/balutil/inc/IBAFunctions.h +++ b/src/api/burn/balutil/inc/IBAFunctions.h @@ -61,4 +61,13 @@ DECLARE_INTERFACE_IID_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49 __inout BOOL* pfProcessed, __inout LRESULT* plResult ) = 0; + + // OnThemeControlLoaded - Called after a control was created for the theme. + // + STDMETHOD(OnThemeControlLoaded)( + __in LPCWSTR wzName, + __in WORD wId, + __in HWND hWnd, + __inout BOOL* pfProcessed + ) = 0; }; diff --git a/src/api/burn/balutil/inc/balutil.h b/src/api/burn/balutil/inc/balutil.h index 82fd1fe5..0c47301a 100644 --- a/src/api/burn/balutil/inc/balutil.h +++ b/src/api/burn/balutil/inc/balutil.h @@ -11,6 +11,7 @@ extern "C" { #define BalExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BalExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitWithRootFailureSource(d, x, e, f, ...) { x = FAILED(e) ? e : E_FAIL; BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BalExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } #define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } @@ -18,6 +19,7 @@ extern "C" { #define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) #define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitWithRootFailure(x, e, f, ...) BalExitWithRootFailureSource(DUTIL_SOURCE_DEFAULT, x, e, f, __VA_ARGS__) #define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) #define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) #define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) diff --git a/src/api/burn/bextutil/inc/bextutil.h b/src/api/burn/bextutil/inc/bextutil.h index ac9c0062..facaf2e8 100644 --- a/src/api/burn/bextutil/inc/bextutil.h +++ b/src/api/burn/bextutil/inc/bextutil.h @@ -11,6 +11,7 @@ extern "C" { #define BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitWithRootFailureSource(d, x, e, f, ...) { x = FAILED(e) ? e : E_FAIL; BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } #define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } #define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } @@ -18,6 +19,7 @@ extern "C" { #define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) #define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitWithRootFailure(x, e, f, ...) BextExitWithRootFailureSource(DUTIL_SOURCE_DEFAULT, x, e, f, __VA_ARGS__) #define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) #define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) #define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) -- cgit v1.2.3-55-g6feb