I am trying to implement a custom control which, as part of its WM_PAINT
handler, paints a themed scroll bar arrow. I also want transitions between the visual states of the button (normal, hot, hover, pressed, and so forth) to have a fade animation using the BeginBufferedAnimation()
family of functions defined in uxtheme.dll
.
My problem right now is that I can't get the correct fade duration for scrollbar because the GetThemeTransitionDuration()
function is failing. Instead of succeeding, it returns E_INVALIDARG
(-2147024809) when I attempt to query the transition duration:
HTHEME hTheme = OpenThemeData(hwnd, L"SCROLLBAR"); // returns a valid non-NULL theme handle
...
DWORD dwDuration = 0;
HRESULT hr = GetThemeTransitionDuration(
hTheme, /*hTheme*/
SBP_ARROWBTN /*iPartId*/,
ABP_LEFTNORMAL /*iStateIdFrom*/,
ABP_LEFTHOT /*iStateIdTo*/,
TMT_TRANSITIONDURATION /*iPropId*/,
&dwDuration /*pdwDuration*/
); // PROBLEM: returns E_INVALIDARG
This is weird for two reasons:
(1) In my version of Windows 7, the themed scrollbars clearly have quick fade animations between states (e.g. in Windows Explorer).
(2) If I change the theme to BUTTON and just use the normal and hot button states, the function returns S_OK
and gives a reasonable transition duration (1000ms on my machine).
HTHEME hTheme = OpenThemeData(hwnd, L"BUTTON");
...
DWORD dwDuration = 0;
HRESULT hr = GetThemeTransitionDuration(
hTheme, /*hTheme*/
BP_PUSHBUTTON /*iPartId*/,
PBS_NORMAL /*iStateIdFrom*/,
PBS_HOT /*iStateIdTo*/,
TMT_TRANSITIONDURATION /*iPropId*/,
&dwDuration /*pdwDuration*/
); // returns S_OK, and dwDuration = 1000
Is there a way to query the transition duration I'm looking for?