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.

246 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. globals.h
  5. Abstract:
  6. Every project needs a globals.h
  7. Revision History:
  8. 7 Feb 2000 v-michka Created.
  9. --*/
  10. #ifndef GLOBALS_H
  11. #define GLOBALS_H
  12. #include <windows.h> // We always need a windows.h
  13. #include <winnls.h> // for GetLocaleInfo
  14. #include <mbstring.h> // for _mbslen
  15. #define MAX_SMALL_STRING MAX_PATH
  16. // TLS Allocation index storage
  17. typedef struct tagGodotTlsInfo
  18. {
  19. // Enumeration callback procedures, owned by the user
  20. CALINFO_ENUMPROCW pfnCalendarInfo;
  21. CALINFO_ENUMPROCEXW pfnCalendarInfoEx;
  22. DATEFMT_ENUMPROCW pfnDateFormats;
  23. DATEFMT_ENUMPROCEXW pfnDateFormatsEx;
  24. LOCALE_ENUMPROCW pfnLocales;
  25. TIMEFMT_ENUMPROCW pfnTimeFormats;
  26. PROPENUMPROCW pfnProp;
  27. PROPENUMPROCA pfnPropA;
  28. PROPENUMPROCEXW pfnPropEx;
  29. PROPENUMPROCEXA pfnPropExA;
  30. FONTENUMPROCW pfnFontFamilies;
  31. FONTENUMPROCW pfnFontFamiliesEx;
  32. FONTENUMPROCW pfnFonts;
  33. ICMENUMPROCW pfnICMProfiles;
  34. GRAYSTRINGPROC pfnGrayString;
  35. UINT cpgGrayString;
  36. // Pointers to the caller's version of the find/replace dialogs
  37. LPFINDREPLACEW lpfrwFind;
  38. LPFINDREPLACEW lpfrwReplace;
  39. // user hook for find/replace/open/save/page setup dialogs (if they exist)
  40. // note that the open save hooks are only for the OFN_EXPLORER
  41. // type dialogs.
  42. LPFRHOOKPROC pfnFindText;
  43. LPFRHOOKPROC pfnReplaceText;
  44. LPOFNHOOKPROC pfnGetOpenFileName;
  45. LPOFNHOOKPROC pfnGetSaveFileName;
  46. LPPAGEPAINTHOOK pfnPagePaint;
  47. // Common dialog hook procedures that we do not hook to do
  48. // significant work with
  49. LPCCHOOKPROC pfnChooseColor;
  50. LPCFHOOKPROC pfnChooseFont;
  51. LPOFNHOOKPROC pfnGetOpenFileNameOldStyle;
  52. LPOFNHOOKPROC pfnGetSaveFileNameOldStyle;
  53. LPPAGESETUPHOOK pfnPageSetup;
  54. LPPRINTHOOKPROC pfnPrintDlg;
  55. LPSETUPHOOKPROC pfnPrintDlgSetup;
  56. // Our refcount members. Note that since they will be stored
  57. // on a per-thread basis, there are no synchronization issues
  58. // with updating them in place.
  59. // WARNING: Note that there are 16 of these, so we are currently
  60. // DWORD aligned. If you add or remove any, make sure that you
  61. // add the appropriate padding.
  62. unsigned short cCalendarInfo : 4;
  63. unsigned short cCalendarInfoEx : 4;
  64. unsigned short cDateFormats : 4;
  65. unsigned short cDateFormatsEx : 4;
  66. unsigned short cLocales : 4;
  67. unsigned short cTimeFormats : 4;
  68. unsigned short cProp : 4;
  69. unsigned short cPropA : 4;
  70. unsigned short cPropEx : 4;
  71. unsigned short cPropExA : 4;
  72. unsigned short cFontFamilies : 4;
  73. unsigned short cFontFamiliesEx : 4;
  74. unsigned short cFonts : 4;
  75. unsigned short cICMProfiles : 4;
  76. unsigned short cGrayString : 4;
  77. unsigned short RESERVED : 4;
  78. // Pointer to our hook procedure handle
  79. // (see the proc, in hook.c, for more info.
  80. HHOOK hHook;
  81. // Pointer to dialog proc (one per thread).
  82. // Our DialogProc will clear it out as soon as
  83. // the init happens.
  84. DLGPROC pfnDlgProc;
  85. } GODOTTLSINFO, *LPGODOTTLSINFO;
  86. #define GODOTMAXREFCOUNT 15
  87. // globals: pretty evil, but there are not many of them. :-)
  88. extern UINT g_acp; // CP_ACP; it is faster to call with the actual cpg
  89. extern UINT g_oemcp; // CP_OEMCP; it is faster to call with the actual cpg
  90. extern UINT g_mcs; // The maximum character size (in bytes) of a character on CP_ACP
  91. extern DWORD g_dwVersion; // The return from GetVersion, used many places
  92. extern UINT g_tls; // GODOT TLS slot - lots of thread-specific info here
  93. extern CRITICAL_SECTION g_csThreads; // Our critical section object for thread data (use sparingly!)
  94. extern CRITICAL_SECTION g_csWnds; // our critical section object for window data (use sparingly!)
  95. // from windowsx.h
  96. #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
  97. // culled from msointl.h, could not find them elsewhere
  98. #define CP_JAPAN 932
  99. #define CP_CHINA 936
  100. #define CP_KOREA 949
  101. #define CP_TAIWAN 950
  102. #define CP_JOHAB 1361
  103. #define CP_GB18030 54936
  104. // code page translation flags
  105. #define NLS_CP_CPINFO 0x10000000
  106. #define NLS_CP_CPINFOEX 0x20000000
  107. #define NLS_CP_MBTOWC 0x40000000
  108. #define NLS_CP_WCTOMB 0x80000000
  109. typedef enum
  110. {
  111. // normal message transmitters
  112. mtSendMessage = 0x00000001,
  113. mtSendMessageCallback = 0x00000002,
  114. mtSendMessageTimeout = 0x00000004,
  115. mtSendNotifyMessage = 0x00000008,
  116. mtPostMessage = 0x00000010,
  117. mtPostThreadMessage = 0x00000020,
  118. mtDefWindowProc = 0x00000040,
  119. mtDefDlgProc = 0x00000080,
  120. mtDefFrameProc = 0x00000100,
  121. mtDefMDIChildProc = 0x00000200,
  122. mtBroadcastSystemMessage = 0x00000400,
  123. mtCallWindowProc = 0x00000800,
  124. mtCallWindowProcA = 0x00001000,
  125. // normal message receivers
  126. mtGetMessage = 0x00010000,
  127. mtPeekMessage = 0x00020000,
  128. // normal message dispatchers
  129. mtDispatchMessage = 0x00040000,
  130. mtIsDialogMessage = 0x00080000,
  131. mtTranslateAccelerator = 0x00100000,
  132. mtSendMessageAndIlk = (mtSendMessage |
  133. mtSendMessageCallback |
  134. mtSendMessageTimeout |
  135. mtSendNotifyMessage),
  136. mtDefWindowProcAndIlk = (mtDefWindowProc |
  137. mtDefDlgProc |
  138. mtDefFrameProc |
  139. mtDefMDIChildProc)
  140. } MESSAGETYPES;
  141. typedef enum
  142. {
  143. fptWndproc = 0x01,
  144. fptDlgproc = 0x02,
  145. fptUnknown = 0x03
  146. } FAUXPROCTYPE;
  147. UINT msgFINDMSGSTRING;
  148. UINT msgHELPMSGSTRING;
  149. UINT msgFILEOKSTRING;
  150. UINT msgSHAREVISTRING;
  151. // MACROS to do some kinda handy things
  152. // Many macros moved to convert.h with deal with memory allocation, etc.
  153. // Are we dealing with a DBCS code page?
  154. #define FDBCS_CPG(cpg) \
  155. (cpg == CP_JAPAN || \
  156. cpg == CP_KOREA || \
  157. cpg == CP_TAIWAN || \
  158. cpg == CP_CHINA || \
  159. cpg == CP_JOHAB || \
  160. cpg == CP_GB18030)
  161. // are we on Windows 95?
  162. #define FWIN95() \
  163. ((FWIN9X() && \
  164. ((DWORD)(HIBYTE(LOWORD(g_dwVersion))) == 0)))
  165. // Are we on Windows 95 or 98?
  166. #define FWIN95_OR_98() \
  167. ((FWIN9X() && \
  168. ((DWORD)(HIBYTE(LOWORD(g_dwVersion))) < 9)))
  169. // Are we on any Win9x platform?
  170. #define FWIN9X() \
  171. ((g_dwVersion >= 0x80000000) && \
  172. (((DWORD)(LOBYTE(LOWORD(g_dwVersion))) == 4)))
  173. #ifndef CDSIZEOF_STRUCT
  174. #define CDSIZEOF_STRUCT(structname, member) \
  175. (((int)((LPBYTE)(&((structname*)0)->member) - \
  176. ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
  177. #endif
  178. // Some size "constants" for RAS, based on the size changes in Millenium
  179. #define CBRASENTRYNAMEOLDA CDSIZEOF_STRUCT(RASENTRYNAMEA,szEntryName)
  180. #define CBRASENTRYNAMEOLDW CDSIZEOF_STRUCT(RASENTRYNAMEW,szEntryName)
  181. #define CBRASDIALPARAMSOLDA CDSIZEOF_STRUCT(RASDIALPARAMSA,szDomain)
  182. #define CBRASDIALPARAMSOLDW CDSIZEOF_STRUCT(RASDIALPARAMSW,szDomain)
  183. #define CBRASDIALPARAMSNEWA CDSIZEOF_STRUCT(RASDIALPARAMSA,dwCallbackId)
  184. #define CBRASDIALPARAMSNEWW CDSIZEOF_STRUCT(RASDIALPARAMSA,dwCallbackId)
  185. #define CBRASENTRYOLDA CDSIZEOF_STRUCT(RASENTRYA,dwReserved2)
  186. #define CBRASENTRYOLDW CDSIZEOF_STRUCT(RASENTRYW,dwReserved2)
  187. #define CBRASENTRYNEWA CDSIZEOF_STRUCT(RASENTRYA,dwIdleDisconnectSeconds)
  188. #define CBRASENTRYNEWW CDSIZEOF_STRUCT(RASENTRYW,dwIdleDisconnectSeconds)
  189. #define CBRASCONNOLDA CDSIZEOF_STRUCT(RASCONNA,szDeviceName)
  190. #define CBRASCONNOLDW CDSIZEOF_STRUCT(RASCONNW,szDeviceName)
  191. #define CBRASCONNNEWA CDSIZEOF_STRUCT(RASCONNA,dwSubEntry)
  192. #define CBRASCONNNEWW CDSIZEOF_STRUCT(RASCONNW,dwSubEntry)
  193. #endif // GLOBALS_H