Leaked source code of windows server 2003
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.

141 lines
4.4 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  2. #ifdef COMPILE_MULTIMON_STUBS
  3. #define COMPILE_MULTIMON_STUBS2
  4. #endif
  5. #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
  6. #include <multimon.h>
  7. //=============================================================================
  8. //
  9. // MULTIMON
  10. // stub module that fakes multiple monitor apis on pre Memphis Win32 OSes
  11. //
  12. // By using this header your code will work unchanged on Win95,
  13. // you will get back default values from GetSystemMetrics() for new metrics
  14. // and the new APIs will act like only one display is present.
  15. //
  16. // exactly one source must include this with COMPILE_MULTIMON_STUBS defined
  17. //
  18. //=============================================================================
  19. #ifdef __cplusplus
  20. extern "C" { /* Assume C declarations for C++ */
  21. #endif /* __cplusplus */
  22. #undef ChangeDisplaySettingsEx
  23. //
  24. // define this to compile the stubs
  25. // otherwise you get the declarations
  26. //
  27. #ifdef COMPILE_MULTIMON_STUBS2
  28. //-----------------------------------------------------------------------------
  29. //
  30. // Implement the API stubs.
  31. //
  32. //-----------------------------------------------------------------------------
  33. BOOL (WINAPI* g_pfnChangeDisplaySettingsEx)(LPCSTR, LPDEVMODE, HWND, DWORD, LPVOID);
  34. BOOL InitMultipleMonitorStubs2(void)
  35. {
  36. HMODULE hUser32;
  37. static BOOL fInitDone;
  38. if (fInitDone)
  39. {
  40. return g_pfnGetMonitorInfo != NULL;
  41. }
  42. if ((hUser32 = GetModuleHandle(TEXT("USER32"))) &&
  43. #ifdef UNICODE
  44. (*(FARPROC*)&g_pfnChangeDisplaySettingsEx = GetProcAddress(hUser32,"ChangeDisplaySettingsExW")) &&
  45. #else
  46. (*(FARPROC*)&g_pfnChangeDisplaySettingsEx = GetProcAddress(hUser32,"ChangeDisplaySettingsExA")) &&
  47. #endif
  48. //
  49. // Old builds of Memphis had different indices for these metrics, and
  50. // some of the APIs and structs have changed since then, so validate that
  51. // the returned metrics are not totally messed up. (for example on an old
  52. // Memphis build, the new index for SM_CYVIRTUALSCREEN will fetch 0)
  53. //
  54. // If this is preventing you from using the shell on secondary monitors
  55. // under Memphis then upgrade to a new Memphis build that is in sync with
  56. // the current version of the multi-monitor APIs.
  57. //
  58. (GetSystemMetrics(SM_CXVIRTUALSCREEN) >= GetSystemMetrics(SM_CXSCREEN)) &&
  59. (GetSystemMetrics(SM_CYVIRTUALSCREEN) >= GetSystemMetrics(SM_CYSCREEN)) )
  60. {
  61. fInitDone = TRUE;
  62. return TRUE;
  63. }
  64. else
  65. {
  66. g_pfnChangeDisplaySettingsEx = NULL ;
  67. fInitDone = TRUE;
  68. return FALSE;
  69. }
  70. }
  71. #ifdef UNICODE
  72. LONG WINAPI
  73. xChangeDisplaySettingsExW(LPCSTR lpszDeviceName, LPDEVMODEW lpDevMode,
  74. HWND hwnd, DWORD dwflags, LPVOID lParam)
  75. {
  76. if (InitMultipleMonitorStubs2())
  77. return g_pfnChangeDisplaySettingsEx(lpszDeviceName, lpDevMode, hwnd,
  78. dwflags, lParam) ;
  79. // Otherwise return DISP_CHANGE_SUCCESSFUL, because OS doesn't support it
  80. return DISP_CHANGE_SUCCESSFUL ; // what else?
  81. }
  82. #else
  83. LONG WINAPI
  84. xChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode,
  85. HWND hwnd, DWORD dwflags, LPVOID lParam)
  86. {
  87. if (InitMultipleMonitorStubs2())
  88. return g_pfnChangeDisplaySettingsEx(lpszDeviceName, lpDevMode, hwnd,
  89. dwflags, lParam) ;
  90. // Otherwise return DISP_CHANGE_SUCCESSFUL, because OS doesn't support it
  91. return DISP_CHANGE_SUCCESSFUL ; // what else?
  92. }
  93. #endif // UNICODE
  94. #undef COMPILE_MULTIMON_STUBS2
  95. #else // COMPILE_MULTIMON_STUBS2
  96. #ifdef UNICODE
  97. extern LONG WINAPI xChangeDisplaySettingsExW(LPCSTR, LPDEVMODE, HWND, DWORD, LPVOID);
  98. #else
  99. extern LONG WINAPI xChangeDisplaySettingsExA(LPCSTR, LPDEVMODE, HWND, DWORD, LPVOID);
  100. #endif
  101. #endif // COMPILE_MULTIMON_STUBS2
  102. //
  103. // build defines that replace the regular APIs with our versions
  104. //
  105. #ifdef UNICODE
  106. #define ChangeDisplaySettingsEx xChangeDisplaySettingsExW
  107. #else
  108. #define ChangeDisplaySettingsEx xChangeDisplaySettingsExA
  109. #define ChangeDisplaySettingsExA xChangeDisplaySettingsExA
  110. #endif
  111. #ifdef __cplusplus
  112. }
  113. #endif /* __cplusplus */
  114. #endif /* !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) */