1   /************************************************************************
  2           Copy Handler 1.x - program for copying data     in Microsoft Windows
  3                                                    systems.
  4           Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl)
  5  
  6           This program is free software; you can redistribute it and/or modify
  7           it under the terms of the GNU General Public License as published by
  8           the Free Software Foundation; either version 2 of the License, or
  9           (at your option) any later version.
  10  
  11           This program is distributed in the hope that it will be useful,
  12           but WITHOUT ANY WARRANTY; without even the implied warranty of
  13           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14           GNU General Public License for more details.
  15  
  16           You should have received a copy of the GNU General Public License
  17           along with this program; if not, write to the Free Software
  18           Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19   *************************************************************************/
  20   #include "stdafx.h"
  21   #include "Theme Helpers.h"
  22  
  23  
  24   CUxThemeSupport::CUxThemeSupport()
  25   {
  26           m_hThemesDll=LoadLibrary(_T("UxTheme.dll"));
  27   }
  28  
  29   CUxThemeSupport::~CUxThemeSupport()
  30   {
  31           if (m_hThemesDll)
  32                   FreeLibrary(m_hThemesDll);
  33   }
  34  
  35   HTHEME CUxThemeSupport::OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
  36   {
  37           ASSERT(m_hThemesDll);
  38  
  39           PFNOPENTHEMEDATA pfnProc=(PFNOPENTHEMEDATA)GetProcAddress(m_hThemesDll, _T("OpenThemeData"));
  40  
  41           if (pfnProc)
  42                   return (*pfnProc)(hwnd, pszClassList);
  43           else
  44                   return NULL;
  45   }
  46  
  47   HRESULT CUxThemeSupport::CloseThemeData(HTHEME hTheme)
  48   {
  49           ASSERT(m_hThemesDll);
  50  
  51           PFNCLOSETHEMEDATA pfnProc=(PFNCLOSETHEMEDATA)GetProcAddress(m_hThemesDll, _T("CloseThemeData"));
  52  
  53           if (pfnProc)
  54                   return (*pfnProc)(hTheme);
  55           else
  56                   return E_UNEXPECTED;
  57   }
  58  
  59   HRESULT CUxThemeSupport::DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect)
  60   {
  61           ASSERT(m_hThemesDll);
  62  
  63           PFNDRAWTHEMEEDGE pfnProc=(PFNDRAWTHEMEEDGE)GetProcAddress(m_hThemesDll, _T("DrawThemeEdge"));
  64  
  65           if (pfnProc)
  66                   return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect);
  67           else
  68                   return E_UNEXPECTED;
  69   }
  70  
  71   HRESULT CUxThemeSupport::DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect)
  72   {
  73           ASSERT(m_hThemesDll);
  74  
  75           PFNDRAWTHEMEBACKGROUND pfnProc=(PFNDRAWTHEMEBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeBackground"));
  76  
  77           if (pfnProc)
  78                   return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
  79           else
  80                   return E_UNEXPECTED;
  81   }
  82  
  83   HRESULT CUxThemeSupport::DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc)
  84   {
  85           ASSERT(m_hThemesDll);
  86  
  87           PFNDRAWTHEMEPARENTBACKGROUND pfnProc=(PFNDRAWTHEMEPARENTBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeParentBackground"));
  88  
  89           if (pfnProc)
  90                   return (*pfnProc)(hwnd, hdc, prc);
  91           else
  92                   return E_UNEXPECTED;
  93   }
  94  
  95   BOOL CUxThemeSupport::IsAppThemed()
  96   {
  97           ASSERT(m_hThemesDll);
  98  
  99           PFNISAPPTHEMED pfnProc=(PFNISAPPTHEMED)GetProcAddress(m_hThemesDll, _T("IsAppThemed"));
  100  
  101           if (pfnProc)
  102                   return (*pfnProc)();
  103           else
  104                   return FALSE;
  105   }