diff --git a/uppsrc/CtrlCore/Win32Proc.cpp b/uppsrc/CtrlCore/Win32Proc.cpp index 971508f2f..17e1cb720 100644 --- a/uppsrc/CtrlCore/Win32Proc.cpp +++ b/uppsrc/CtrlCore/Win32Proc.cpp @@ -8,6 +8,8 @@ namespace Upp { +void XpClear(); // Clear cached windows theme handles + #define LLOG(x) // DLOG(x) dword Ctrl::KEYtoK(dword chr) { @@ -528,7 +530,7 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if(owner && (owner->IsForeground() || IsForeground()) && !owner->SetWantFocus()) IterateFocusForward(owner, owner); } - if(IsWindowUnicode(hwnd)) // TRC 04/10/17: ActiveX unicode patch + if(IsWindowUnicode(hwnd)) DefWindowProcW(hwnd, message, wParam, lParam); else DefWindowProc(hwnd, message, wParam, lParam); @@ -590,6 +592,8 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { case WM_ACTIVATE: LLOG("WM_ACTIVATE " << Name() << ", wParam = " << (int)wParam << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd) << ", raw = " << (void *)::GetFocus()); ignorekeyup = true; + case 0x031A: // WM_THEMECHANGED + XpClear(); break; case WM_SETFOCUS: LLOG("WM_SETFOCUS " << Name() << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd) << ", raw = " << (void *)::GetFocus()); diff --git a/uppsrc/CtrlLib/ChWin32.cpp b/uppsrc/CtrlLib/ChWin32.cpp index 0def98412..9b03c4e89 100644 --- a/uppsrc/CtrlLib/ChWin32.cpp +++ b/uppsrc/CtrlLib/ChWin32.cpp @@ -1,5 +1,7 @@ #include "CtrlLib.h" +// #define STATIC_IMAGES // avoids calling theming API while app is running - probably wrong path + #ifdef GUI_WIN #define LLOG(x) // RLOG(x) @@ -63,7 +65,11 @@ static VectorMap xp_opaque; void XpClear() { - memset(xp_widget_handle, 0, sizeof(xp_widget_handle)); + for(int i = 0; i < XP_COUNT; i++) + if(xp_widget_handle[i]) { + XpTheme().CloseThemeData(xp_widget_handle[i]); + xp_widget_handle[i] = NULL; + } xp_margin.Clear(); xp_opaque.Clear(); } @@ -210,6 +216,7 @@ struct Win32ImageMaker : ImageMaker { } }; +#ifndef STATIC_IMAGES Value XpLookFn(Draw& w, const Rect& rect, const Value& v, int op, Color) { if(IsTypeRaw(v)) { @@ -271,6 +278,7 @@ Value XpLookFn(Draw& w, const Rect& rect, const Value& v, int op, Color) } return Null; } +#endif struct chCtrlsImg { int id; @@ -297,7 +305,22 @@ void Win32Look(Value *ch, int count, int widget, int part, int state = 1, bool c e.part = part; e.state = state + i; e.contentm = contentm; + #ifdef STATIC_IMAGES + Image m = XpImage(widget, part, state + i); + int hotspot; + if(contentm) { + Rect r(0, 0, 100, 100); + Rect cr; + HANDLE htheme = XpWidget(widget); + XpTheme().GetThemeBackgroundContentRect(htheme, NULL, e.part, e.state, r, cr); + hotspot = cr.left; + } + else + hotspot = XpMargin(e); + ch[i] = WithHotSpot(m, hotspot, hotspot); + #else ch[i] = RawToValue(e); + #endif } } @@ -441,7 +464,9 @@ void ChHostSkin() } else SColorDisabled_Write(Color(0x80, 0x80, 0x80)); +#ifndef STATIC_IMAGES ChLookFn(XpLookFn); +#endif if(XpWidget(XP_BUTTON)) { GUI_GlobalStyle_Write(GUISTYLE_XP);