+// ----------------------------------------------------------------------------
+// wxUxThemeHandle: encapsulates ::Open/CloseThemeData()
+// ----------------------------------------------------------------------------
+
+class wxUxThemeHandle
+{
+public:
+ wxUxThemeHandle(wxWindow *win, const wchar_t *classes)
+ {
+ wxUxThemeEngine *engine = wxUxThemeEngine::Get();
+
+ m_hTheme =
+ engine ? (WXHTHEME)engine->OpenThemeData(win->GetHWND(), classes)
+ : NULL;
+ }
+
+ operator WXHTHEME() const { return m_hTheme; }
+
+ ~wxUxThemeHandle()
+ {
+ if ( m_hTheme )
+ {
+ wxUxThemeEngine::Get()->CloseThemeData(m_hTheme);
+ }
+ }
+
+private:
+ WXHTHEME m_hTheme;
+
+ DECLARE_NO_COPY_CLASS(wxUxThemeHandle)
+};
+