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.

317 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. sdprg.h
  5. Abstract:
  6. IIS Shutdown/restart dialog definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "inetmgr.h"
  18. #include "sdprg.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. //
  25. // Timer ID and values
  26. //
  27. #define ID_TIMER (1)
  28. #define A_SECOND (1000L)
  29. CShutProgressDlg::CShutProgressDlg(
  30. IN IISCOMMAND * pCommand
  31. )
  32. /*++
  33. Routine Description:
  34. Constructor for shutdown progress dialog
  35. Arguments:
  36. IISCOMMAND * pCommand : Command structure
  37. Return Value:
  38. N/A
  39. --*/
  40. : CDialog(CShutProgressDlg::IDD, pCommand->pParent),
  41. m_pCommand(pCommand),
  42. m_uTimeoutSec(pCommand->dwMilliseconds / A_SECOND)
  43. {
  44. //{{AFX_DATA_INIT(CShutProgressDlg)
  45. //}}AFX_DATA_INIT
  46. }
  47. void
  48. CShutProgressDlg::DoDataExchange(
  49. IN CDataExchange * pDX
  50. )
  51. /*++
  52. Routine Description:
  53. Initialise/Store control data
  54. Arguments:
  55. CDataExchange * pDX - DDX/DDV control structure
  56. Return Value:
  57. None
  58. --*/
  59. {
  60. CDialog::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CShutProgressDlg)
  62. DDX_Control(pDX, IDC_STATIC_PROGRESS, m_static_ProgressMsg);
  63. DDX_Control(pDX, IDC_PROGRESS_SHUTDOWN, m_prgShutdown);
  64. //}}AFX_DATA_MAP
  65. }
  66. //
  67. // Message Map
  68. //
  69. BEGIN_MESSAGE_MAP(CShutProgressDlg, CDialog)
  70. //{{AFX_MSG_MAP(CShutProgressDlg)
  71. ON_WM_TIMER()
  72. ON_WM_DESTROY()
  73. //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75. //
  76. // Message Handlers
  77. //
  78. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  79. BOOL
  80. CShutProgressDlg::OnInitDialog()
  81. /*++
  82. Routine Description:
  83. WM_INITDIALOG handler. Initialize the dialog.
  84. Arguments:
  85. None.
  86. Return Value:
  87. TRUE if no focus is to be set automatically, FALSE if the focus
  88. is already set.
  89. --*/
  90. {
  91. CDialog::OnInitDialog();
  92. VERIFY(m_strProgress.LoadString(IDS_SHUTDOWN_PROGRESS));
  93. m_nProgress = 0;
  94. #if _MFC_VER >= 0x0600
  95. m_prgShutdown.SetRange32(0, m_uTimeoutSec);
  96. #else
  97. m_prgShutdown.SetRange(0, m_uTimeoutSec);
  98. #endif
  99. m_prgShutdown.SetPos(m_nProgress);
  100. m_prgShutdown.SetStep(1);
  101. //
  102. // Start the progress bar ticking, once per second.
  103. //
  104. UINT_PTR nID = SetTimer(ID_TIMER, A_SECOND, NULL);
  105. if (nID != ID_TIMER)
  106. {
  107. //
  108. // Failed to create the timer. Pop up an error, and
  109. // cancel the dialog.
  110. //
  111. CError err(ERROR_NO_SYSTEM_RESOURCES);
  112. err.MessageBox();
  113. EndDialog(IDCANCEL);
  114. }
  115. return TRUE;
  116. }
  117. void
  118. CShutProgressDlg::OnTimer(
  119. IN UINT nIDEvent
  120. )
  121. /*++
  122. Routine Description:
  123. Timer handler. Upgrade the progressbar with another second on the clock
  124. Arguments:
  125. UINT nIDEvent : Timer id
  126. Return Value:
  127. None
  128. --*/
  129. {
  130. ASSERT(nIDEvent == ID_TIMER);
  131. m_prgShutdown.SetPos(++m_nProgress);
  132. //
  133. // Display progress on the tick marker
  134. //
  135. CString str;
  136. str.Format(m_strProgress, m_uTimeoutSec - (UINT)m_nProgress + 1);
  137. m_static_ProgressMsg.SetWindowText(str);
  138. //
  139. // Check to see if the stop thread has finished its action already
  140. //
  141. BOOL fFinished;
  142. EnterCriticalSection(&m_pCommand->cs);
  143. fFinished = m_pCommand->fFinished;
  144. LeaveCriticalSection(&m_pCommand->cs);
  145. if (fFinished)
  146. {
  147. //
  148. // The worker thread has finished, so there's no reason to
  149. // keep the user in suspense -- dismiss the dialog
  150. //
  151. EndDialog(IDCANCEL);
  152. }
  153. if ((UINT)m_nProgress > m_uTimeoutSec)
  154. {
  155. //
  156. // We've timed out -- tell the main thread to Kill!()
  157. //
  158. OnOK();
  159. }
  160. //
  161. // I doubt there's any default processing here, but anyway...
  162. //
  163. CDialog::OnTimer(nIDEvent);
  164. }
  165. void
  166. CShutProgressDlg::OnDestroy()
  167. /*++
  168. Routine Description:
  169. Handle dialog destruction, kill the timer.
  170. Arguments:
  171. None
  172. Return Value:
  173. None
  174. --*/
  175. {
  176. CDialog::OnDestroy();
  177. KillTimer(ID_TIMER);
  178. }
  179. void
  180. CShutProgressDlg::OnOK()
  181. /*++
  182. Routine Description:
  183. OK handler -- ok button maps to "Kill Now!"
  184. Arguments:
  185. None
  186. Return Value:
  187. None
  188. --*/
  189. {
  190. //
  191. // Kill!
  192. //
  193. EndDialog(IDOK);
  194. }
  195. void
  196. CShutProgressDlg::OnCancel()
  197. /*++
  198. Routine Description:
  199. Cancel button handler. This dialog cannot be cancelled, so the cancel
  200. notification is eaten.
  201. Arguments:
  202. None
  203. Return Value:
  204. None
  205. --*/
  206. {
  207. //
  208. // Eat cancel command (user pressed escape)
  209. //
  210. }