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.

276 lines
8.2 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #undef AFX_DATA
  11. #define AFX_DATA AFX_CORE_DATA
  12. /////////////////////////////////////////////////////////////////////////////
  13. // Auxiliary System/Screen metrics
  14. struct AUX_DATA
  15. {
  16. // system metrics
  17. int cxVScroll, cyHScroll;
  18. int cxIcon, cyIcon;
  19. int cxBorder2, cyBorder2;
  20. // device metrics for screen
  21. int cxPixelsPerInch, cyPixelsPerInch;
  22. int cySysFont;
  23. // solid brushes with convenient gray colors and system colors
  24. HBRUSH hbrLtGray, hbrDkGray;
  25. HBRUSH hbrBtnHilite, hbrBtnFace, hbrBtnShadow;
  26. HBRUSH hbrWindowFrame;
  27. HPEN hpenBtnHilite, hpenBtnShadow, hpenBtnText;
  28. // color values of system colors used for CToolBar
  29. COLORREF clrBtnFace, clrBtnShadow, clrBtnHilite;
  30. COLORREF clrBtnText, clrWindowFrame;
  31. // standard cursors
  32. HCURSOR hcurWait;
  33. HCURSOR hcurArrow;
  34. HCURSOR hcurHelp; // cursor used in Shift+F1 help
  35. // special GDI objects allocated on demand
  36. HFONT hStatusFont;
  37. HFONT hToolTipsFont;
  38. HBITMAP hbmMenuDot;
  39. // other system information
  40. UINT nWinVer; // Major.Minor version numbers
  41. BOOL bWin32s; // TRUE if Win32s (or Windows 95)
  42. BOOL bWin4; // TRUE if Windows 4.0
  43. BOOL bNotWin4; // TRUE if not Windows 4.0
  44. BOOL bSmCaption; // TRUE if WS_EX_SMCAPTION is supported
  45. BOOL bWin31; // TRUE if actually Win32s on Windows 3.1
  46. BOOL bMarked4; // TRUE if marked as 4.0
  47. // special Windows API entry points
  48. int (WINAPI* pfnSetScrollInfo)(HWND, int, LPCSCROLLINFO, BOOL);
  49. BOOL (WINAPI* pfnGetScrollInfo)(HWND, int, LPSCROLLINFO);
  50. // Implementation
  51. AUX_DATA();
  52. ~AUX_DATA();
  53. void UpdateSysColors();
  54. void UpdateSysMetrics();
  55. };
  56. extern AFX_DATA AUX_DATA afxData;
  57. ////////////////////////////////////////////////////////////////////////////
  58. // other global state
  59. #ifdef _WINDLL
  60. extern DWORD _afxAppTlsIndex;
  61. extern AFX_APP_STATE* _afxAppState;
  62. #endif
  63. extern DWORD _afxThreadTlsIndex;
  64. // Note: afxData.cxBorder and afxData.cyBorder aren't used anymore
  65. #define CX_BORDER 1
  66. #define CY_BORDER 1
  67. // states for Shift+F1 hep mode
  68. #define HELP_INACTIVE 0 // not in Shift+F1 help mode (must be 0)
  69. #define HELP_ACTIVE 1 // in Shift+F1 help mode (non-zero)
  70. #define HELP_ENTERING 2 // entering Shift+F1 help mode (non-zero)
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Window class names and other window creation support
  73. // from wincore.cpp
  74. extern const TCHAR _afxWnd[]; // simple child windows/controls
  75. extern const TCHAR _afxWndControlBar[]; // controls with grey backgrounds
  76. extern const TCHAR _afxWndMDIFrame[];
  77. extern const TCHAR _afxWndFrameOrView[];
  78. INT_PTR CALLBACK AfxDlgProc(HWND, UINT, WPARAM, LPARAM);
  79. UINT_PTR CALLBACK _AfxCommDlgProc(HWND hWnd, UINT, WPARAM, LPARAM);
  80. // Support for standard dialogs
  81. extern const UINT _afxNMsgSETRGB;
  82. typedef UINT_PTR (CALLBACK* COMMDLGPROC)(HWND, UINT, WPARAM, LPARAM);
  83. /////////////////////////////////////////////////////////////////////////////
  84. // Special helpers
  85. HWND AFXAPI AfxGetSafeOwner(CWnd* pParent, HWND* phTopLevel = NULL);
  86. void AFXAPI AfxCancelModes(HWND hWndRcvr);
  87. HWND AFXAPI AfxGetParentOwner(HWND hWnd);
  88. BOOL AFXAPI AfxIsDescendant(HWND hWndParent, HWND hWndChild);
  89. BOOL AFXAPI AfxHelpEnabled(); // determine if ID_HELP handler exists
  90. void AFXAPI AfxDeleteObject(HGDIOBJ* pObject);
  91. BOOL AFXAPI AfxCustomLogFont(UINT nIDS, LOGFONT* pLogFont);
  92. BOOL AFXAPI _AfxIsComboBoxControl(HWND hWnd, UINT nStyle);
  93. BOOL AFXAPI _AfxCheckCenterDialog(LPCTSTR lpszResource);
  94. #ifdef _MAC
  95. BOOL AFXAPI _AfxIdenticalRect(LPCRECT lpRectOne, LPCRECT lpRectTwo);
  96. #else
  97. #define _AfxIdenticalRect EqualRect
  98. #endif
  99. // UNICODE/MBCS abstractions
  100. #ifdef _MBCS
  101. extern const BOOL _afxDBCS;
  102. #else
  103. #define _afxDBCS FALSE
  104. #endif
  105. // determine number of elements in an array (not bytes)
  106. #define _countof(array) (sizeof(array)/sizeof(array[0]))
  107. //#define UNUSED // usage: UNUSED formal_arg
  108. /////////////////////////////////////////////////////////////////////////////
  109. // useful message ranges
  110. #define WM_SYSKEYFIRST WM_SYSKEYDOWN
  111. #define WM_SYSKEYLAST WM_SYSDEADCHAR
  112. #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
  113. #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
  114. /////////////////////////////////////////////////////////////////////////////
  115. // AFX_CRITICAL_SECTION
  116. #pragma warning(disable: 4097)
  117. class AFX_CRITICAL_SECTION : public CRITICAL_SECTION
  118. {
  119. // Constructors & Operations
  120. public:
  121. AFX_CRITICAL_SECTION();
  122. // Attributes
  123. operator CRITICAL_SECTION*();
  124. // Implementation
  125. public:
  126. ~AFX_CRITICAL_SECTION();
  127. private:
  128. // no implementation (CRITICAL_SECTION objects cannot be copied)
  129. AFX_CRITICAL_SECTION(const AFX_CRITICAL_SECTION&);
  130. void operator=(const AFX_CRITICAL_SECTION&);
  131. };
  132. inline AFX_CRITICAL_SECTION::AFX_CRITICAL_SECTION()
  133. { ::InitializeCriticalSection(this); }
  134. inline AFX_CRITICAL_SECTION::operator CRITICAL_SECTION*()
  135. { return (CRITICAL_SECTION*)this; }
  136. inline AFX_CRITICAL_SECTION::~AFX_CRITICAL_SECTION()
  137. { ::DeleteCriticalSection(this); }
  138. #pragma warning(default: 4097)
  139. // global critical section for general thread safe access
  140. extern AFX_DATA AFX_CRITICAL_SECTION _afxCriticalSection;
  141. /////////////////////////////////////////////////////////////////////////////
  142. // Portability abstractions
  143. #define _AfxSetDlgCtrlID(hWnd, nID) SetWindowLong(hWnd, GWL_ID, nID)
  144. #define _AfxGetDlgCtrlID(hWnd) ((UINT)(WORD)::GetDlgCtrlID(hWnd))
  145. // misc helpers
  146. BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn);
  147. BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2);
  148. UINT AFXAPI AfxGetFileTitle(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax);
  149. UINT AFXAPI AfxGetFileName(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax);
  150. #ifdef _MAC
  151. #define AfxGetFileName AfxGetFileTitle
  152. #endif
  153. const AFX_MSGMAP_ENTRY* AFXAPI
  154. AfxFindMessageEntry(const AFX_MSGMAP_ENTRY* lpEntry,
  155. UINT nMsg, UINT nCode, UINT nID);
  156. #define NULL_TLS ((DWORD)-1)
  157. /////////////////////////////////////////////////////////////////////////////
  158. // Debugging/Tracing helpers
  159. #ifdef _DEBUG
  160. void AFXAPI _AfxTraceMsg(LPCTSTR lpszPrefix, const MSG* pMsg);
  161. BOOL AFXAPI _AfxCheckDialogTemplate(LPCTSTR lpszResource,
  162. BOOL bInvisibleChild);
  163. #endif
  164. /////////////////////////////////////////////////////////////////////////////
  165. // Win4 specific defines
  166. #if (WINVER < 0x400)
  167. // new window styles
  168. #define WS_EX_SMCAPTION 0x00000080L
  169. #define WS_EX_WINDOWEDGE 0x00000100L
  170. #define WS_EX_CLIENTEDGE 0x00000200L
  171. // new dialog styles
  172. #define DS_3DLOOK 0x00000004L
  173. // new scroll bar styles
  174. #define SBS_SIZEGRIP 0x00000010L
  175. // new common dialog flags
  176. #define OFN_EXPLORER 0x00080000L
  177. // new color metrics
  178. #define COLOR_INFOTEXT 23
  179. #define COLOR_INFOBK 24
  180. #endif //(WINVER < 0x400)
  181. #ifndef WS_EX_SMCAPTION
  182. #define WS_EX_SMCAPTION WS_EX_TOOLWINDOW
  183. #endif
  184. #ifndef WM_DISPLAYCHANGE
  185. #define WM_DISPLAYCHANGE 0x007E
  186. #endif
  187. /////////////////////////////////////////////////////////////////////////////
  188. // Macintosh-specific declarations
  189. #ifdef _MAC
  190. #include <macname1.h>
  191. #include <Types.h>
  192. #include <QuickDraw.h>
  193. #include <AppleEvents.h>
  194. #include <macname2.h>
  195. extern AEEventHandlerUPP _afxPfnOpenApp;
  196. extern AEEventHandlerUPP _afxPfnOpenDoc;
  197. extern AEEventHandlerUPP _afxPfnPrintDoc;
  198. extern AEEventHandlerUPP _afxPfnQuit;
  199. OSErr PASCAL _AfxOpenAppHandler(AppleEvent* pae, AppleEvent* paeReply, long lRefcon);
  200. OSErr PASCAL _AfxOpenDocHandler(AppleEvent* pae, AppleEvent* paeReply, long lRefcon);
  201. OSErr PASCAL _AfxPrintDocHandler(AppleEvent* pae, AppleEvent* paeReply, long lRefcon);
  202. OSErr PASCAL _AfxQuitHandler(AppleEvent* pae, AppleEvent* paeReply, long lRefcon);
  203. void AFXAPI _AfxStripDialogCaption(HINSTANCE hInst, LPCTSTR lpszResource);
  204. GDHandle AFXAPI _AfxFindDevice(int x, int y);
  205. BOOL AFXAPI AfxCheckMonochrome(const RECT* pRect);
  206. HFONT AFXAPI _AfxGetHelpFont();
  207. #endif //_MAC
  208. #undef AFX_DATA
  209. #define AFX_DATA
  210. /////////////////////////////////////////////////////////////////////////////