ThemeHelperST.cpp
上传用户:dengkfang
上传日期:2008-12-30
资源大小:5233k
文件大小:3k
源码类别:

CA认证

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "ThemeHelperST.h"
  3. #ifdef _DEBUG
  4. #undef THIS_FILE
  5. static char THIS_FILE[]=__FILE__;
  6. #define new DEBUG_NEW
  7. #endif
  8. CThemeHelperST::CThemeHelperST()
  9. {
  10. // Load DLL. This call will fails (and return NULL) if
  11. // we are not running under Windows XP (or greater)
  12. m_hDll = ::LoadLibrary(_T("UxTheme.dll"));
  13. }
  14. CThemeHelperST::~CThemeHelperST()
  15. {
  16. // Unload DLL (if any)
  17. if (m_hDll) ::FreeLibrary(m_hDll);
  18. m_hDll = NULL;
  19. }
  20. LPVOID CThemeHelperST::GetProc(LPCSTR szProc, LPVOID pfnFail)
  21. {
  22. LPVOID lpRet = pfnFail;
  23. if (m_hDll)
  24. lpRet = GetProcAddress(m_hDll, szProc);
  25. return lpRet;
  26. } // End of GetProc
  27. HTHEME CThemeHelperST::OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
  28. {
  29. PFNOPENTHEMEDATA pfnOpenThemeData = (PFNOPENTHEMEDATA)GetProc("OpenThemeData", (LPVOID)OpenThemeDataFail);
  30. return (*pfnOpenThemeData)(hwnd, pszClassList);
  31. } // End of OpenThemeData
  32. HRESULT CThemeHelperST::CloseThemeData(HTHEME hTheme)
  33. {
  34. PFNCLOSETHEMEDATA pfnCloseThemeData = (PFNCLOSETHEMEDATA)GetProc("CloseThemeData", (LPVOID)CloseThemeDataFail);
  35. return (*pfnCloseThemeData)(hTheme);
  36. } // End of CloseThemeData
  37. HRESULT CThemeHelperST::DrawThemeBackground(HTHEME hTheme, HWND hWnd, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect)
  38. {
  39.   PFNDRAWTHEMEPARENTBACKGROUND pfnDrawThemeParentBackground = (PFNDRAWTHEMEPARENTBACKGROUND)GetProc("DrawThemeParentBackground", NULL);
  40.   if (pfnDrawThemeParentBackground && hWnd)
  41.   {    
  42.   (*pfnDrawThemeParentBackground)(hWnd, hdc, (PRECT)pRect);  
  43.   } // if
  44.   
  45.   PFNDRAWTHEMEBACKGROUND pfnDrawThemeBackground = (PFNDRAWTHEMEBACKGROUND)GetProc("DrawThemeBackground", (LPVOID)DrawThemeBackgroundFail);
  46. return (*pfnDrawThemeBackground)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
  47. } // End of DrawThemeBackground
  48. //new
  49. /*HRESULT CThemeHelperST::DrawThemeBackground(HTHEME hTheme, HWND hWnd, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect)
  50. {
  51. PFNDRAWTHEMEPARENTBACKGROUND pfnDrawThemeParentBackground = (PFNDRAWTHEMEPARENTBACKGROUND)GetProc("DrawThemeParentBackground", NULL);
  52. if (pfnDrawThemeParentBackground)
  53. {
  54. (*pfnDrawThemeParentBackground)(hWnd, hdc, (PRECT)pRect);
  55. }
  56.     PFNDRAWTHEMEBACKGROUND pfnDrawThemeBackground = (PFNDRAWTHEMEBACKGROUND)GetProc("DrawThemeBackground", (LPVOID)DrawThemeBackgroundFail);
  57. return (*pfnDrawThemeBackground)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
  58. } // End of DrawThemeBackground*/
  59. HRESULT CThemeHelperST::DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect)
  60. {
  61. PFNDRAWTHEMETEXT pfn = (PFNDRAWTHEMETEXT)GetProc("DrawThemeText", (LPVOID)DrawThemeTextFail);
  62. return (*pfn)(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags2, pRect);
  63. } // End of DrawThemeText
  64. BOOL CThemeHelperST::IsAppThemed()
  65. {
  66. PFNISAPPTHEMED pfnIsAppThemed = (PFNISAPPTHEMED)GetProc("IsAppThemed", (LPVOID)IsAppThemedFail);
  67. return (*pfnIsAppThemed)();
  68. } // End of IsAppThemed
  69. BOOL CThemeHelperST::IsThemeActive()
  70. {
  71. PFNISTHEMEACTIVE pfn = (PFNISTHEMEACTIVE)GetProc("IsThemeActive", (LPVOID)IsThemeActiveFail);
  72. return (*pfn)();
  73. } // End of IsThemeActive