Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.0 KiB

  1. //---------------------------------------------------------------------------//
  2. // globals.cpp - variables shared by uxtheme modules
  3. //---------------------------------------------------------------------------//
  4. // NOTE: global variables in this module are NOT protected by a critical
  5. // section are subject to being set by 2 different threads at the same
  6. // time. Therefore, these variables should only be set during uxtheme init.
  7. //---------------------------------------------------------------------------//
  8. #include "stdafx.h"
  9. #include "globals.h"
  10. #include "AppInfo.h"
  11. #include "services.h"
  12. #include "ThemeFile.h"
  13. #include "RenderList.h"
  14. #include "CacheList.h"
  15. #include "bmpcache.h"
  16. //---------------------------------------------------------------------------//
  17. HINSTANCE g_hInst = NULL;
  18. WCHAR g_szProcessName[MAX_PATH] = {0};
  19. DWORD g_dwProcessId = 0;
  20. BOOL g_fUxthemeInitialized = FALSE;
  21. BOOL g_fEarlyHookRequest = FALSE;
  22. HWND g_hwndFirstHooked = 0;
  23. THEMEHOOKSTATE g_eThemeHookState = HS_UNINITIALIZED;
  24. CAppInfo *g_pAppInfo = NULL;
  25. CRenderList *g_pRenderList = NULL;
  26. CBitmapCache *g_pBitmapCacheScaled = NULL;
  27. CBitmapCache *g_pBitmapCacheUnscaled = NULL;
  28. #ifdef LAME_BUTTON
  29. void InitLameText();
  30. #else
  31. #define InitLameText()
  32. #endif
  33. //---------------------------------------------------------------------------
  34. BOOL GlobalsStartup()
  35. {
  36. BOOL fInit = FALSE;
  37. Log(LOG_TMSTARTUP, L"GlobalsStartup");
  38. g_dwProcessId = GetCurrentProcessId();
  39. //---- create global objects ----
  40. CThemeServices::StaticInitialize();
  41. g_pRenderList = new CRenderList();
  42. if (! g_pRenderList)
  43. goto exit;
  44. g_pAppInfo = new CAppInfo();
  45. if (! g_pAppInfo)
  46. goto exit;
  47. WCHAR szPath[MAX_PATH];
  48. if (! GetModuleFileNameW( NULL, szPath, ARRAYSIZE(szPath) ))
  49. goto exit;
  50. WCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szExt[_MAX_EXT];
  51. _wsplitpath(szPath, szDrive, szDir, g_szProcessName, szExt);
  52. g_pBitmapCacheScaled = new CBitmapCache();
  53. if (! g_pBitmapCacheScaled)
  54. goto exit;
  55. g_pBitmapCacheUnscaled = new CBitmapCache();
  56. if (! g_pBitmapCacheUnscaled)
  57. goto exit;
  58. InitLameText();
  59. if (g_fEarlyHookRequest)
  60. {
  61. //---- May want to PostMessage() a request to theme ldr ----
  62. //---- to trigger our hooks & send us WM_THEMECHANGED msg ---
  63. //---- if it looks like some apps need this. For now, ----
  64. //---- let's see if just relying on queued us msgs to do work ----
  65. //---- is sufficient. ----
  66. }
  67. g_fUxthemeInitialized = TRUE;
  68. fInit = TRUE;
  69. exit:
  70. return fInit;
  71. }
  72. //---------------------------------------------------------------------------//
  73. BOOL GlobalsShutdown()
  74. {
  75. Log(LOG_TMSTARTUP, L"GlobalsShutDown");
  76. SAFE_DELETE(g_pBitmapCacheScaled);
  77. SAFE_DELETE(g_pBitmapCacheUnscaled);
  78. SAFE_DELETE(g_pAppInfo);
  79. SAFE_DELETE(g_pRenderList);
  80. CThemeServices::StaticTerminate();
  81. g_fUxthemeInitialized = FALSE;
  82. return TRUE;
  83. }
  84. //---------------------------------------------------------------------------//
  85. HWINSTA _GetWindowStation( LPTSTR pszName, int cchName )
  86. {
  87. HWINSTA hWinsta = GetProcessWindowStation();
  88. *pszName = 0;
  89. if( hWinsta != NULL )
  90. {
  91. DWORD cbNeeded = 0;
  92. GetUserObjectInformation( hWinsta, UOI_NAME, pszName, cchName, &cbNeeded );
  93. }
  94. return hWinsta;
  95. }
  96. //---------------------------------------------------------------------------//
  97. HRESULT BumpThemeFileRefCount(CUxThemeFile *pThemeFile)
  98. {
  99. HRESULT hr;
  100. if (g_pAppInfo)
  101. hr = g_pAppInfo->BumpRefCount(pThemeFile);
  102. else
  103. hr = MakeError32(E_FAIL);
  104. return hr;
  105. }
  106. //---------------------------------------------------------------------------//
  107. void CloseThemeFile(CUxThemeFile *pThemeFile)
  108. {
  109. if (g_pAppInfo)
  110. g_pAppInfo->CloseThemeFile(pThemeFile);
  111. }
  112. //---------------------------------------------------------------------------