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.

179 lines
4.9 KiB

  1. //
  2. // QuickRes.h
  3. //
  4. #include <windows.h>
  5. #include <shellapi.h>
  6. #include "QuickRes.rc"
  7. #include "stdlib.h"
  8. #include "tchar.h"
  9. #define ODS OutputDebugString
  10. #define TRAY_MSG WM_USER+1
  11. #define TRAY_ID 42
  12. //
  13. // Global Quickres bit flags
  14. //
  15. #define QF_SHOWRESTART 0x0001 // Show modes that require a restart
  16. #define QF_UPDATEREG 0x0002 // update registry with new devmode
  17. #define QF_REMMODES 0x0004 // Remember good/bad modes in registry
  18. #define QF_SORT_BYBPP 0x0008 // if not set, we sort by Resolution
  19. #define QF_HIDE_4BPP 0x0010 // Hide 4Bpp mode if 8Bpp of same res exists
  20. #define QF_SHOWTESTED 0x0020 // Show tested/passing modes only
  21. #define QF_SHOWFREQS 0x0040 // Show Frequencies (disabled on Win95)
  22. //
  23. // fGoodModes (below) depends on these values for these flags
  24. // Changing these constants requires rewriting the fGoodModes macro
  25. //
  26. #define MODE_INVALID 0 // Devmode is not visible
  27. #define MODE_VALID 1 // Devmode looks good
  28. #define MODE_UNTESTED 2 // Haven't tried it yet
  29. #define MODE_BESTHZ 3 // Best Hz for given res/bpp
  30. #define RESOURCE_STRINGLEN 512 // Guess at largest resource string length
  31. #define KEEP_RES_TIMEOUT 15 // how long before reverting to old devmode
  32. #define INT_FORMAT_TO_5_DIGITS 10 // Need 3+ more bytes : "%d" -> "12345"
  33. // Being safe here (add 10 bytes)
  34. //
  35. // Constant strings in registry & for starting properties
  36. //
  37. #define REGSTR_SOFTWARE TEXT("Software\\Microsoft")
  38. #define REGSTR_QUICKRES TEXT("Software\\Microsoft\\QuickRes")
  39. #define QUICKRES_KEY TEXT("QuickRes")
  40. #define DISPLAYPROPERTIES TEXT("rundll32 shell32.dll,Control_RunDLL desk.cpl,,3")
  41. #define REGDEVMODES TEXT("GoodDevmodes")
  42. #define REGBPP TEXT("BPP")
  43. #define REGFLAGS TEXT("Flags")
  44. #ifdef UNICODE
  45. #define ENUMDISPLAYDEVICES "EnumDisplayDevicesW"
  46. #define ENUMDISPLAYSETTINGSEX "EnumDisplaySettingsExW"
  47. #else
  48. #define ENUMDISPLAYDEVICES "EnumDisplayDevicesA"
  49. #define ENUMDISPLAYSETTINGSEX "EnumDisplaySettingsExA"
  50. #endif
  51. //
  52. // Each devmode has 4 additional properties.
  53. //
  54. typedef struct _DEVMODEINFO {
  55. DEVMODE dm;
  56. UINT uFreqMenu;
  57. UINT uMenuItem;
  58. UINT uCDSTest;
  59. UINT uValidMode;
  60. } DEVMODEINFO, *LPDEVMODEINFO;
  61. //
  62. // Per monitor information :
  63. // devicename, monitorname
  64. // devmode menu and freq submenus built on the fly
  65. // iModes : number of devmodes
  66. // pModes : array of devmodes display can handle
  67. // pCurrentdm : pointer (in pModes) to current devmode
  68. // bPrimary : primary or not?
  69. //
  70. typedef struct _QRMONITORINFO
  71. {
  72. LPTSTR DeviceName;
  73. LPTSTR MonitorName;
  74. LPTSTR PrimaryMonitorName;
  75. HMENU ModeMenu;
  76. HMENU *FreqMenu;
  77. INT iModes;
  78. LPDEVMODEINFO pModes;
  79. LPDEVMODEINFO pCurrentdm;
  80. BOOL bPrimary;
  81. BOOL bAttached;
  82. } QRMONITORINFO, *LPQRMONITORINFO;
  83. //
  84. // prototypes
  85. //
  86. // quickres.c
  87. //
  88. HMENU GetModeMenu ( INT, BOOL );
  89. HMENU GetMonitorMenu ( BOOL );
  90. BOOL BuildDevmodeList ( VOID );
  91. BOOL TrayMessage( HWND, DWORD, UINT, HICON );
  92. int MsgBox( int, UINT, UINT );
  93. VOID CheckMenuItemCurrentMode( INT );
  94. PDEVMODE GetCurrentDevMode( INT, PDEVMODE );
  95. LPTSTR GetResourceString( UINT );
  96. VOID DestroyModeMenu( INT, BOOL, BOOL );
  97. VOID AppendMainMenu( VOID );
  98. INT_PTR FAR PASCAL KeepNewResDlgProc( HWND, UINT, WPARAM, LPARAM );
  99. INT_PTR FAR PASCAL NTOptionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  100. INT_PTR FAR PASCAL W95OptionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  101. //
  102. // registry.c
  103. //
  104. VOID SetDevmodeFlags ( INT, BOOL );
  105. VOID GetDevmodeFlags ( INT );
  106. VOID SetQuickResFlags( VOID );
  107. VOID GetQuickResFlags( VOID );
  108. VOID SetRegistryValue( LPTSTR, UINT, PVOID, UINT );
  109. VOID SaveAllSettings ( VOID );
  110. //
  111. //Macros
  112. //
  113. #define fShowModesThatNeedRestart (QuickResFlags & QF_SHOWRESTART)
  114. #define fUpdateReg (QuickResFlags & QF_UPDATEREG)
  115. #define fRememberModes (QuickResFlags & QF_REMMODES)
  116. #define fSortByBPP (QuickResFlags & QF_SORT_BYBPP)
  117. #define fHide4BppModes (QuickResFlags & QF_HIDE_4BPP)
  118. #define fShowTestedModes (QuickResFlags & QF_SHOWTESTED)
  119. #define fShowFreqs (QuickResFlags & QF_SHOWFREQS)
  120. //
  121. // Devmode info
  122. //
  123. #define BPP(x) ((x)->dmBitsPerPel)
  124. #define XRES(x) ((x)->dmPelsWidth)
  125. #define YRES(x) ((x)->dmPelsHeight)
  126. #define HZ(x) ((x)->dmDisplayFrequency)
  127. #define FREQMENU(x) ((x)->uFreqMenu)
  128. #define MENUITEM(x) ((x)->uMenuItem)
  129. #define CDSTEST(x) ((x)->uCDSTest)
  130. #define VALIDMODE(x) ((x)->uValidMode)
  131. //
  132. // Must leave MODE_VALID=1, MODE_BESTHZ=3.
  133. // Other MODE_* constants should be even
  134. #define fGoodMode(x) ((x)->uValidMode & 0x1)