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.

172 lines
5.7 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: mfcstl/shims/attribute/get_HWND.hpp
  3. *
  4. * Purpose: Contains access shims for windows.
  5. *
  6. * Created: 10th January 2003
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2003-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file mfcstl/shims/attribute/get_HWND.hpp
  40. *
  41. * \brief [C++ only] Definition of stlsoft::get_HWND attribute shim
  42. * functions for MFC types
  43. * (\ref group__library__shims__window_attribute "Window Attribute Shims").
  44. */
  45. #ifndef MFCSTL_INCL_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND
  46. #define MFCSTL_INCL_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define MFCSTL_VER_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND_MAJOR 4
  49. # define MFCSTL_VER_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND_MINOR 1
  50. # define MFCSTL_VER_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND_REVISION 1
  51. # define MFCSTL_VER_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND_EDIT 43
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
  57. # include <mfcstl/mfcstl.hpp>
  58. #endif /* !MFCSTL_INCL_MFCSTL_HPP_MFCSTL */
  59. # include <afxwin.h>
  60. /* /////////////////////////////////////////////////////////////////////////
  61. * Namespace
  62. */
  63. #ifndef _MFCSTL_NO_NAMESPACE
  64. # if defined(_STLSOFT_NO_NAMESPACE) || \
  65. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  66. /* There is no stlsoft namespace, so must define ::mfcstl */
  67. namespace mfcstl
  68. {
  69. # else
  70. /* Define stlsoft::mfcstl_project */
  71. namespace stlsoft
  72. {
  73. namespace mfcstl_project
  74. {
  75. # endif /* _STLSOFT_NO_NAMESPACE */
  76. #endif /* !_MFCSTL_NO_NAMESPACE */
  77. /* /////////////////////////////////////////////////////////////////////////
  78. * get_HWND
  79. *
  80. * This can be applied to an expression, and the return value is the
  81. * corresponding HWND.
  82. */
  83. /* HWND */
  84. /** \brief Access the HWND of the given CWnd instance
  85. *
  86. * \ingroup group__library__shims__window_attribute
  87. *
  88. * This access <a href = "http://stlsoft.org/white_papers.html#shims">shim</a> retrieves the
  89. * HWND window handle for the given CWnd instance.
  90. *
  91. * \param w A reference to the CWnd instance whose HWND will be retrieved
  92. * \return The HWND corresponding to the given CWnd instance \c w
  93. *
  94. */
  95. inline HWND get_HWND(CWnd const& w)
  96. {
  97. return w.m_hWnd;
  98. }
  99. /** \brief Access the HWND of the given CWnd instance
  100. *
  101. * \ingroup group__library__shims__window_attribute
  102. *
  103. * This access <a href = "http://stlsoft.org/white_papers.html#shims">shim</a> retrieves the
  104. * HWND window handle for the given CWnd instance.
  105. *
  106. * \param w A pointer to the CWnd instance whose HWND will be retrieved
  107. * \return The HWND corresponding to the given CWnd instance \c w
  108. *
  109. */
  110. inline HWND get_HWND(CWnd const* w)
  111. {
  112. return w->GetSafeHwnd();
  113. }
  114. ////////////////////////////////////////////////////////////////////////////
  115. // Unit-testing
  116. #ifdef STLSOFT_UNITTEST
  117. # include "./unittest/get_HWND_unittest_.h"
  118. #endif /* STLSOFT_UNITTEST */
  119. /* ////////////////////////////////////////////////////////////////////// */
  120. #ifndef _MFCSTL_NO_NAMESPACE
  121. # if defined(_STLSOFT_NO_NAMESPACE) || \
  122. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  123. } // namespace mfcstl
  124. # else
  125. } // namespace mfcstl_project
  126. } // namespace stlsoft
  127. # endif /* _STLSOFT_NO_NAMESPACE */
  128. #else /* ? _MFCSTL_NO_NAMESPACE */
  129. # if !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  130. # if !defined(_WINSTL_NO_NAMESPACE)
  131. # if defined(_STLSOFT_NO_NAMESPACE)
  132. namespace winstl
  133. {
  134. using ::mfcstl::get_HWND;
  135. } // namespace winstl
  136. # else /* ? _STLSOFT_NO_NAMESPACE */
  137. namespace stlsoft
  138. {
  139. namespace winstl_project
  140. {
  141. using ::mfcstl::get_HWND;
  142. } // namespace winstl_project
  143. } // namespace stlsoft
  144. # endif /* _STLSOFT_NO_NAMESPACE */
  145. # endif /* !_WINSTL_NO_NAMESPACE */
  146. # endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  147. #endif /* !_MFCSTL_NO_NAMESPACE */
  148. /* ////////////////////////////////////////////////////////////////////// */
  149. #endif /* MFCSTL_INCL_MFCSTL_SHIMS_ATTRIBUTE_HPP_GET_HWND */
  150. /* ///////////////////////////// end of file //////////////////////////// */