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.

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