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.

215 lines
5.2 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1998 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AtlBaseDlg.h
  7. //
  8. // Desription:
  9. // Definition of the CBaseDlg class.
  10. //
  11. // Author:
  12. // David Potter (davidp) February 9, 1998
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #ifndef __ATLBASEDLG_H_
  20. #define __ATLBASEDLG_H_
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Forward Class Declarations
  23. /////////////////////////////////////////////////////////////////////////////
  24. template < class T > class CBaseDlg;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // External Class Declarations
  27. /////////////////////////////////////////////////////////////////////////////
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Include Files
  30. /////////////////////////////////////////////////////////////////////////////
  31. #ifndef __ATLDBGWIN_H_
  32. #include "AtlDbgWin.h" // for DBG_xxx routines
  33. #endif
  34. #ifndef __ATLPOPUPHELP_H_
  35. #include "AtlPopupHelp.h" // for COnlineHelp
  36. #endif
  37. #ifndef __CTRLUTIL_H
  38. #include "DlgItemUtils.h" // for CDlgItemUtils
  39. #endif
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Type Definitions
  42. /////////////////////////////////////////////////////////////////////////////
  43. /////////////////////////////////////////////////////////////////////////////
  44. //++
  45. //
  46. // class CBaseDlg
  47. //
  48. // Description:
  49. // Base dialog class. Provides the following features:
  50. // -- Popup help.
  51. // -- Dialog item utilities.
  52. // -- Debugging support.
  53. //
  54. // Inheritance:
  55. // CBaseDlg< T >
  56. // CDialogImpl< T >, CPopupHelp< T >, CDlgItemUtils
  57. //
  58. //--
  59. /////////////////////////////////////////////////////////////////////////////
  60. template< class T >
  61. class CBaseDlg
  62. : public CDialogImpl< T >
  63. , public CPopupHelp< T >
  64. , public CDlgItemUtils
  65. {
  66. typedef CBaseDlg< T > thisClass;
  67. typedef CDialogImpl< T > baseClass;
  68. public:
  69. //
  70. // Construction
  71. //
  72. // Constructor taking a string pointer for the title
  73. CBaseDlg(
  74. IN OUT LPCTSTR lpszTitle = NULL
  75. )
  76. {
  77. if ( lpszTitle != NULL )
  78. {
  79. m_strTitle = lpszTitle;
  80. } // if: title specified
  81. } //*** CBaseDlg( lpszTitle )
  82. // Constructor taking a resource ID for the title
  83. CBaseDlg( IN UINT nIDTitle )
  84. {
  85. m_strTitle.LoadString( nIDTitle );
  86. } //*** CBaseDlg( nIDTitle )
  87. // Initialize the page
  88. virtual BOOL BInit( void )
  89. {
  90. return TRUE;
  91. } //*** BInit()
  92. protected:
  93. //
  94. // CBasePage helper methods.
  95. //
  96. // Attach a control to a dialog item.
  97. void AttachControl( CWindow & rwndControl, UINT idc )
  98. {
  99. HWND hwndControl = GetDlgItem( idc );
  100. ATLASSERT( hwndControl != NULL );
  101. rwndControl.Attach( hwndControl );
  102. } //*** AttachControl()
  103. public:
  104. //
  105. // CBaseDlg public methods to override.
  106. //
  107. // Update data on or from the page
  108. virtual BOOL UpdateData( BOOL bSaveAndValidate )
  109. {
  110. return TRUE;
  111. } //*** UpdateData()
  112. public:
  113. //
  114. // Message handler functions.
  115. //
  116. BEGIN_MSG_MAP( CBaseDlg< T > )
  117. MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
  118. #if DBG
  119. #ifdef _DBG_MSG
  120. MESSAGE_RANGE_HANDLER( 0, 0xffffffff, OnMsg )
  121. #endif // _DBG_MSG
  122. #ifdef _DBG_MSG_NOTIFY
  123. MESSAGE_HANDLER( WM_NOTIFY, OnNotify )
  124. #endif // _DBG_MSG_NOTIFY
  125. #ifdef _DBG_MSG_COMMAND
  126. MESSAGE_HANDLER( WM_COMMAND, OnCommand )
  127. #endif // _DBG_MSG_COMMAND
  128. #endif // DBG
  129. CHAIN_MSG_MAP( CPopupHelp< T > )
  130. END_MSG_MAP()
  131. // Handler for the WM_INITDIALOG message
  132. LRESULT OnInitDialog(
  133. UINT uMsg,
  134. WPARAM wParam,
  135. LPARAM lParam,
  136. BOOL & bHandled
  137. )
  138. {
  139. T * pT = static_cast< T * >( this );
  140. return pT->OnInitDialog();
  141. } //*** OnInitDialog()
  142. // Handler for the WM_INITDIALOG message
  143. LRESULT OnInitDialog( void )
  144. {
  145. return TRUE;
  146. } //*** OnInitDialog()
  147. #if DBG && defined( _DBG_MSG )
  148. // Handler for any message
  149. LRESULT OnMsg( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  150. {
  151. return DBG_OnMsg( uMsg, wParam, lParam, bHandled, T::s_pszClassName );
  152. } //*** OnMsg()
  153. #endif // DBG && defined( _DBG_MSG )
  154. #if DBG && defined( _DBG_MSG_NOTIFY )
  155. // Handler for the WM_NOTIFY message
  156. LRESULT OnNotify( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  157. {
  158. return DBG_OnNotify( uMsg, wParam, lParam, bHandled, T::s_pszClassName, T::s_rgmapCtrlNames );
  159. } //*** OnNotify()
  160. #endif // DBG && defined( _DBG_MSG_NOTIFY )
  161. #if DBG && defined( _DBG_MSG_COMMAND )
  162. // Handler for the WM_COMMAND message
  163. LRESULT OnCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  164. {
  165. return DBG_OnCommand( uMsg, wParam, lParam, bHandled, T::s_pszClassName, T::s_rgmapCtrlNames );
  166. } //*** OnCommand()
  167. #endif // DBG && defined( _DBG_MSG_COMMAND )
  168. // Implementation
  169. protected:
  170. CString m_strTitle; // Used to support resource IDs for the title.
  171. const CString & StrTitle( void ) const { return m_strTitle; }
  172. }; //*** class CBaseDlg
  173. /////////////////////////////////////////////////////////////////////////////
  174. #endif // __ATLBASEDLG_H_