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.

140 lines
3.8 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: wrapper.h
  7. *
  8. * Contents: Interface file for simple wrapper classes
  9. *
  10. * History: 02-Feb-98 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef WRAPPER_H
  14. #define WRAPPER_H
  15. /*----------------*/
  16. /* HACCEL wrapper */
  17. /*----------------*/
  18. class CAccel : public CObject
  19. {
  20. public:
  21. HACCEL m_hAccel;
  22. CAccel (HACCEL hAccel = NULL);
  23. CAccel (LPACCEL paccl, int cEntries);
  24. ~CAccel ();
  25. bool CreateAcceleratorTable (LPACCEL paccl, int cEntries);
  26. int CopyAcceleratorTable (LPACCEL paccl, int cEntries) const;
  27. bool TranslateAccelerator (HWND hwnd, LPMSG pmsg) const;
  28. void DestroyAcceleratorTable ();
  29. bool LoadAccelerators (int nAccelID);
  30. bool LoadAccelerators (LPCTSTR pszAccelName);
  31. bool LoadAccelerators (HINSTANCE hInst, LPCTSTR pszAccelName);
  32. bool operator== (int i) const
  33. { ASSERT (i == NULL); return (m_hAccel == NULL); }
  34. bool operator!= (int i) const
  35. { ASSERT (i == NULL); return (m_hAccel != NULL); }
  36. operator HACCEL() const
  37. { return (m_hAccel); }
  38. };
  39. /*---------------------------------*/
  40. /* Begin/EndDeferWindowPos wrapper */
  41. /*---------------------------------*/
  42. class CDeferWindowPos
  43. {
  44. public:
  45. HDWP m_hdwp;
  46. CDeferWindowPos (int cWindows = 0, bool fSynchronousPositioningForDebugging = false);
  47. ~CDeferWindowPos ();
  48. bool Begin (int cWindows);
  49. bool End ();
  50. bool AddWindow (const CWnd* pwnd, const CRect& rect, DWORD dwFlags, const CWnd* pwndInsertAfter = NULL);
  51. bool operator== (int i) const
  52. { ASSERT (i == NULL); return (m_hdwp == NULL); }
  53. bool operator!= (int i) const
  54. { ASSERT (i == NULL); return (m_hdwp != NULL); }
  55. operator HDWP() const
  56. { return (m_hdwp); }
  57. private:
  58. const bool m_fSynchronousPositioningForDebugging;
  59. };
  60. /*-------------------*/
  61. /* Rectangle helpers */
  62. /*-------------------*/
  63. class CWindowRect : public CRect
  64. {
  65. public:
  66. CWindowRect (const CWnd* pwnd)
  67. {
  68. if (pwnd != NULL)
  69. pwnd->GetWindowRect (this);
  70. else
  71. SetRectEmpty();
  72. }
  73. /*
  74. * just forward other ctors
  75. */
  76. CWindowRect(int l, int t, int r, int b) : CRect(l, t, r, b) {}
  77. CWindowRect(const RECT& srcRect) : CRect(srcRect) {}
  78. CWindowRect(LPCRECT lpSrcRect) : CRect(lpSrcRect) {}
  79. CWindowRect(POINT point, SIZE size) : CRect(point, size) {}
  80. CWindowRect(POINT topLeft, POINT bottomRight) : CRect(topLeft, bottomRight) {}
  81. };
  82. class CClientRect : public CRect
  83. {
  84. public:
  85. CClientRect (const CWnd* pwnd)
  86. {
  87. if (pwnd != NULL)
  88. pwnd->GetClientRect (this);
  89. else
  90. SetRectEmpty();
  91. }
  92. /*
  93. * just forward other ctors
  94. */
  95. CClientRect(int l, int t, int r, int b) : CRect(l, t, r, b) {}
  96. CClientRect(const RECT& srcRect) : CRect(srcRect) {}
  97. CClientRect(LPCRECT lpSrcRect) : CRect(lpSrcRect) {}
  98. CClientRect(POINT point, SIZE size) : CRect(point, size) {}
  99. CClientRect(POINT topLeft, POINT bottomRight) : CRect(topLeft, bottomRight) {}
  100. };
  101. /*+-------------------------------------------------------------------------*
  102. * AMCGetSysColorBrush
  103. *
  104. * Returns a (temporary) MFC-friendly system color brush.
  105. *--------------------------------------------------------------------------*/
  106. inline CBrush* AMCGetSysColorBrush (int nIndex)
  107. {
  108. return (CBrush::FromHandle (::GetSysColorBrush (nIndex)));
  109. }
  110. #endif /* WRAPPER.H */