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.

170 lines
5.0 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: util.h
  5. //
  6. // History:
  7. //
  8. // 04/13/97 Kenn Takara Created.
  9. //
  10. // Declarations for some common code/macros.
  11. //============================================================================
  12. #ifndef _UTIL_H
  13. #define _UTIL_H
  14. #if _MSC_VER >= 1000 // VC 5.0 or later
  15. #pragma once
  16. #endif
  17. #ifndef _TFSINT_H
  18. #include "tfsint.h"
  19. #endif
  20. ///////////////////////////////////////////////////////////////////////////////
  21. // CWatermarkInfo
  22. typedef struct _WATERMARKINFO
  23. {
  24. HBITMAP hHeader;
  25. HBITMAP hWatermark;
  26. HPALETTE hPalette;
  27. BOOL bStretch;
  28. } WATERMARKINFO, * LPWATERMARKINFO;
  29. TFSCORE_API(HRESULT)
  30. InitWatermarkInfo(HINSTANCE hInstance,
  31. LPWATERMARKINFO pWatermarkInfo,
  32. UINT uIDHeader,
  33. UINT uIDWatermark,
  34. HPALETTE hPalette,
  35. BOOL bStretch);
  36. TFSCORE_API(HRESULT)
  37. ResetWatermarkInfo(LPWATERMARKINFO pWatermarkInfo);
  38. ////////////////////////////////////////////////////////////////////
  39. // CHiddenWnd : Hidden window to syncronize threads and CComponentData object
  40. // When the handler receives the notification messages, it is running
  41. // on the main thread (and can thus call MMC interfaces).
  42. //
  43. // If you need a background thread and don't need to access any of
  44. // the MMC interfaces, you should create a pure worker thread instead
  45. // of using this mechanism. The whole point of this is to synchronize
  46. // our data calls with MMC (because they're a single-threaded app). *sigh*
  47. // maximum number of threads we will be able to handle
  48. // actually the max number is one less
  49. // This value must be a multiple of 32
  50. #define HIDDENWND_MAXTHREADS (512)
  51. // These are the predefined messages for this window
  52. //
  53. /*---------------------------------------------------------------------------
  54. WM_HIDDENWND_REGISTER
  55. wParam - TRUE if to register, FALSE to unregister
  56. lParam - if registering this is ignored
  57. if unregistering, this is the base value (the value that was
  58. returned by the call).
  59. RETURNS: the base value to use when posting the notifications
  60. returns 0 on error
  61. ---------------------------------------------------------------------------*/
  62. #define WM_HIDDENWND_REGISTER WM_USER
  63. /*---------------------------------------------------------------------------
  64. WM_HIDDENWND_INDEX_HAVEDATA
  65. wParam - this is an ITFSThreadHandler *
  66. lParam - private data communication between the QueryObject and
  67. the parent node.
  68. RETURNS: N/A, use PostMessage() for this
  69. ---------------------------------------------------------------------------*/
  70. #define WM_HIDDENWND_INDEX_HAVEDATA (0)
  71. /*---------------------------------------------------------------------------
  72. WM_HIDDENWND_INDEX_ERROR
  73. wParam - this is an ITFSThreadHandler *
  74. lParam - contains HRESULT
  75. RETURNS: N/A, use PostMessage() for this
  76. ---------------------------------------------------------------------------*/
  77. #define WM_HIDDENWND_INDEX_ERROR (1)
  78. /*---------------------------------------------------------------------------
  79. WM_HIDDENWND_INDEX_EXITING
  80. wParam - this is an ITFSThreadHandler *
  81. lParam - not used
  82. RETURNS: N/A, use PostMessage() for this
  83. ---------------------------------------------------------------------------*/
  84. #define WM_HIDDENWND_INDEX_EXITING (2)
  85. #define WM_HIDDENWND_INDEX_LAST (2)
  86. #define WM_HIDDENWND_INDEX_MAX (15)
  87. class CHiddenWnd : public CWnd
  88. {
  89. public:
  90. CHiddenWnd()
  91. {
  92. DEBUG_INCREMENT_INSTANCE_COUNTER(CHiddenWnd);
  93. }
  94. ~CHiddenWnd()
  95. {
  96. DEBUG_DECREMENT_INSTANCE_COUNTER(CHiddenWnd);
  97. }
  98. BOOL Create();
  99. private:
  100. BOOL FIsIdRegistered(UINT uObjectId);
  101. DWORD m_bitMask[(HIDDENWND_MAXTHREADS >> 5)+1];
  102. int m_iLastObjectIdSet;
  103. DWORD m_dwContext;
  104. public:
  105. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  106. afx_msg LONG OnNotifyHaveData(WPARAM wParam, LPARAM lParam);
  107. afx_msg LONG OnNotifyError(WPARAM wParam, LPARAM lParam);
  108. afx_msg LONG OnNotifyExiting(WPARAM wParam, LPARAM lParam);
  109. //{{AFX_MSG(CHiddenWnd)
  110. afx_msg LONG OnNotifyRegister(WPARAM wParam, LPARAM lParam);
  111. //}}AFX_MSG
  112. DECLARE_MESSAGE_MAP()
  113. };
  114. #define WM_TO_OBJECTID(wm) ((((wm)-WM_USER) >> 4))
  115. #define WM_TO_MSGID(wm) (((wm)-WM_USER) & 0x0000000F)
  116. #define OBJECTID_TO_WM(ob) ((((ob)) << 4) + WM_USER)
  117. #define SetBitMask(x,n) (x[n>>5] |= (1 << (n%32)))
  118. #define ClearBitMask(x,n) (x[n>>5] &= ~(1 << (n%32)))
  119. #define IsBitMaskSet(x,n) (x[n>>5] & (1 << (n%32)))
  120. #ifdef __cplusplus
  121. extern "C" {
  122. #endif
  123. TFSCORE_API(HRESULT) LoadAndAddMenuItem(
  124. IContextMenuCallback* pIContextMenuCallback,
  125. LPCTSTR pszMenuString,
  126. LONG lCommandID,
  127. LONG lInsertionPointID,
  128. LONG fFlags,
  129. LPCTSTR pszLangIndStr = NULL);
  130. #ifdef __cplusplus
  131. } // extern "C"
  132. #endif
  133. #endif