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.

271 lines
5.1 KiB

  1. #ifndef _DLG_H_
  2. #define _DLG_H_
  3. /*++
  4. Copyright (c) 2000 Microsoft Corporation
  5. Module Name:
  6. DLG.CPP
  7. Abstract:
  8. C_Dlg implementation
  9. Author:
  10. 990518 dane Created.
  11. georgema 000310 updated
  12. Environment:
  13. Win98, Win2000
  14. Revision History:
  15. --*/
  16. #include <windows.h>
  17. #include <commctrl.h>
  18. #include <tchar.h>
  19. #include "macros.h"
  20. #include <shfusion.h>
  21. //////////////////////////////////////////////////////////////////////////////
  22. //
  23. // C_Dlg
  24. //
  25. // Base dialog class: handles default message routing and processing.
  26. //
  27. class C_Dlg
  28. {
  29. public: // operations
  30. C_Dlg(
  31. HWND hwndParent,
  32. HINSTANCE hInstance,
  33. LONG lIDD,
  34. DLGPROC pfnDlgProc = NULL
  35. );
  36. ~C_Dlg( );
  37. virtual INT_PTR
  38. DoModal(
  39. LPARAM lparam = NULL
  40. );
  41. BOOL
  42. EndDialog(
  43. INT nResult = 0
  44. )
  45. {
  46. ASSERT(NULL != m_hwnd);
  47. return ::EndDialog(m_hwnd, nResult);
  48. } // EndDialog
  49. // Link the object to the window handle
  50. //
  51. virtual BOOL
  52. OnInitDialog(
  53. HWND hwndDlg,
  54. HWND hwndFocus
  55. )
  56. {
  57. // Save the page's window handle & link the window handle to the page
  58. // object.
  59. //
  60. m_hwnd = hwndDlg;
  61. LinkHwnd( );
  62. // Let the system set the default keyboard focus.
  63. //
  64. return TRUE;
  65. } //
  66. virtual BOOL
  67. OnDestroyDialog(void)
  68. {
  69. return TRUE;
  70. }
  71. virtual BOOL
  72. OnCommand(
  73. WORD wNotifyCode,
  74. WORD wId,
  75. HWND hwndSender
  76. )
  77. {
  78. // Message was not processed
  79. //
  80. return FALSE;
  81. } //
  82. virtual BOOL
  83. OnHelpInfo(
  84. LPARAM lParam
  85. )
  86. {
  87. // Message was not processed
  88. //
  89. return FALSE;
  90. } //
  91. virtual BOOL
  92. OnContextMenu(
  93. WPARAM wParam,
  94. LPARAM lParam
  95. )
  96. {
  97. // Message was not processed
  98. //
  99. return FALSE;
  100. } //
  101. virtual BOOL
  102. OnQueryCancel( )
  103. {
  104. // The message was not processed.
  105. //
  106. return FALSE;
  107. } //
  108. virtual BOOL
  109. OnHelp( )
  110. {
  111. // User has clicked the Help button.
  112. // TODO: Display help
  113. // The message was not processed.
  114. //
  115. return FALSE;
  116. } //
  117. virtual BOOL
  118. OnNotify(
  119. LPNMHDR pnmh
  120. )
  121. {
  122. // Message was not processed.
  123. //
  124. return FALSE;
  125. } //
  126. virtual void
  127. CenterWindow();
  128. virtual void
  129. OnShutdown() {
  130. return;
  131. }
  132. #if 0
  133. // Notification message return their results via the DWL_MSGRESULT window
  134. // long. This wrapper keeps me from having to remember that.
  135. //
  136. virtual LONG
  137. SetNotificationMessageResult(
  138. LONG lResult
  139. )
  140. {
  141. return SetWindowLong(m_hwnd, DWL_MSGRESULT, lResult);
  142. } // SetNotificationMessageResult
  143. #endif
  144. // Process application-specific messages (WM_APP + n)
  145. //
  146. virtual BOOL
  147. OnAppMessage(
  148. UINT uMessage,
  149. WPARAM wparam,
  150. LPARAM lparam
  151. )
  152. {
  153. // Message was not processed.
  154. //
  155. return FALSE;
  156. } // OnAppMessage
  157. static HRESULT
  158. DlgFromHwnd(
  159. HWND hwnd,
  160. C_Dlg** ppDlg
  161. );
  162. const HWND
  163. Hwnd( ) const
  164. {
  165. return m_hwnd;
  166. } // Hwnd
  167. virtual void
  168. AssertValid( ) const
  169. {
  170. ASSERT(NULL != m_hwnd);
  171. } // AssertValid
  172. protected: // operations
  173. static LPCTSTR SZ_HWND_PROP;
  174. BOOL
  175. LinkHwnd( );
  176. BOOL
  177. UnlinkHwnd( );
  178. static BOOL CALLBACK
  179. DlgProc(
  180. HWND hwndDlg,
  181. UINT uMessage,
  182. WPARAM wparam,
  183. LPARAM lparam
  184. );
  185. static BOOL
  186. RouteNotificationMessage(
  187. C_Dlg* pDlg,
  188. NMHDR* pnmhdr
  189. );
  190. protected: // data
  191. // Window handle of the dialog's parent window (may be NULL)
  192. //
  193. HWND m_hwndParent;
  194. // Window handle of the dialog (may NOT be NULL)
  195. //
  196. HWND m_hwnd;
  197. // Instance handle of the application displaying this dialog (may be NULL)
  198. //
  199. HINSTANCE m_hInstance;
  200. // Identifier for the dialog template associated with this object
  201. //
  202. LONG m_lIDD;
  203. // Procedure that processes message sent to this dialog
  204. //
  205. DLGPROC m_pfnDlgProc;
  206. private: // operations
  207. // Explicitly disallow copy constructor and assignment operator.
  208. //
  209. C_Dlg(
  210. const C_Dlg& rhs
  211. );
  212. C_Dlg&
  213. operator=(
  214. const C_Dlg& rhs
  215. );
  216. private: // data
  217. }; // C_Dlg
  218. #endif // _DLG_H_
  219. //
  220. ///// End of file: DLG.h ////////////////////////////////////////////////