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.

318 lines
9.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PrtSpool.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CPrintSpoolerParamsPage class.
  10. //
  11. // Author:
  12. // David Potter (davidp) October 17, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "CluAdmX.h"
  21. #include "ExtObj.h"
  22. #include "PrtSpool.h"
  23. #include "DDxDDv.h"
  24. #include "HelpData.h" // for g_rghelpmap*
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CPrintSpoolerParamsPage property page
  32. /////////////////////////////////////////////////////////////////////////////
  33. IMPLEMENT_DYNCREATE(CPrintSpoolerParamsPage, CBasePropertyPage)
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Message Maps
  36. BEGIN_MESSAGE_MAP(CPrintSpoolerParamsPage, CBasePropertyPage)
  37. //{{AFX_MSG_MAP(CPrintSpoolerParamsPage)
  38. ON_EN_CHANGE(IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR, OnChangeSpoolDir)
  39. //}}AFX_MSG_MAP
  40. // TODO: Modify the following lines to represent the data displayed on this page.
  41. ON_EN_CHANGE(IDC_PP_PRTSPOOL_PARAMS_TIMEOUT, CBasePropertyPage::OnChangeCtrl)
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. //++
  45. //
  46. // CPrintSpoolerParamsPage::CPrintSpoolerParamsPage
  47. //
  48. // Routine Description:
  49. // Default constructor.
  50. //
  51. // Arguments:
  52. // None.
  53. //
  54. // Return Value:
  55. // None.
  56. //
  57. //--
  58. /////////////////////////////////////////////////////////////////////////////
  59. CPrintSpoolerParamsPage::CPrintSpoolerParamsPage(void)
  60. : CBasePropertyPage(g_aHelpIDs_IDD_PP_PRTSPOOL_PARAMETERS, g_aHelpIDs_IDD_WIZ_PRTSPOOL_PARAMETERS)
  61. {
  62. // TODO: Modify the following lines to represent the data displayed on this page.
  63. //{{AFX_DATA_INIT(CPrintSpoolerParamsPage)
  64. m_strSpoolDir = _T("");
  65. m_nJobCompletionTimeout = 0;
  66. //}}AFX_DATA_INIT
  67. // Setup the property array.
  68. {
  69. m_rgProps[epropSpoolDir].Set(REGPARAM_PRTSPOOL_DEFAULT_SPOOL_DIR, m_strSpoolDir, m_strPrevSpoolDir);
  70. m_rgProps[epropTimeout].Set(REGPARAM_PRTSPOOL_TIMEOUT, m_nJobCompletionTimeout, m_nPrevJobCompletionTimeout);
  71. } // Setup the property array
  72. m_iddPropertyPage = IDD_PP_PRTSPOOL_PARAMETERS;
  73. m_iddWizardPage = IDD_WIZ_PRTSPOOL_PARAMETERS;
  74. } //*** CPrintSpoolerParamsPage::CPrintSpoolerParamsPage()
  75. /////////////////////////////////////////////////////////////////////////////
  76. //++
  77. //
  78. // CPrintSpoolerParamsPage::HrInit
  79. //
  80. // Routine Description:
  81. // Initialize the page.
  82. //
  83. // Arguments:
  84. // peo [IN OUT] Pointer to the extension object.
  85. //
  86. // Return Value:
  87. // S_OK Page initialized successfully.
  88. // hr Page failed to initialize.
  89. //
  90. //--
  91. /////////////////////////////////////////////////////////////////////////////
  92. HRESULT CPrintSpoolerParamsPage::HrInit(IN OUT CExtObject * peo)
  93. {
  94. HRESULT _hr;
  95. CWaitCursor _wc;
  96. do
  97. {
  98. // Call the base class method.
  99. _hr = CBasePropertyPage::HrInit(peo);
  100. if (FAILED(_hr))
  101. break;
  102. if (BWizard())
  103. m_nJobCompletionTimeout = 160;
  104. else
  105. {
  106. // Convert the job completion timeout to seconds.
  107. m_nPrevJobCompletionTimeout = m_nJobCompletionTimeout;
  108. m_nJobCompletionTimeout = (m_nJobCompletionTimeout + 999) / 1000;
  109. } // else: not creating new resource
  110. } while ( 0 );
  111. return _hr;
  112. } //*** CPrintSpoolerParamsPage::HrInit()
  113. /////////////////////////////////////////////////////////////////////////////
  114. //++
  115. //
  116. // CPrintSpoolerParamsPage::DoDataExchange
  117. //
  118. // Routine Description:
  119. // Do data exchange between the dialog and the class.
  120. //
  121. // Arguments:
  122. // pDX [IN OUT] Data exchange object
  123. //
  124. // Return Value:
  125. // None.
  126. //
  127. //--
  128. /////////////////////////////////////////////////////////////////////////////
  129. void CPrintSpoolerParamsPage::DoDataExchange(CDataExchange * pDX)
  130. {
  131. if (!pDX->m_bSaveAndValidate || !BSaved())
  132. {
  133. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  134. // TODO: Modify the following lines to represent the data displayed on this page.
  135. //{{AFX_DATA_MAP(CPrintSpoolerParamsPage)
  136. DDX_Control(pDX, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR, m_editSpoolDir);
  137. DDX_Text(pDX, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR, m_strSpoolDir);
  138. DDX_Text(pDX, IDC_PP_PRTSPOOL_PARAMS_TIMEOUT, m_nJobCompletionTimeout);
  139. //}}AFX_DATA_MAP
  140. if (!BBackPressed())
  141. {
  142. DDX_Number(pDX, IDC_PP_PRTSPOOL_PARAMS_TIMEOUT, m_nJobCompletionTimeout, 0, 0x7fffffff / 1000);
  143. }
  144. if (pDX->m_bSaveAndValidate && !BBackPressed())
  145. {
  146. DDV_RequiredText(pDX, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR_LABEL, m_strSpoolDir);
  147. DDV_MaxChars(pDX, m_strSpoolDir, MAX_PATH);
  148. DDV_Path(pDX, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR, IDC_PP_PRTSPOOL_PARAMS_SPOOL_DIR_LABEL, m_strSpoolDir);
  149. } // if: saving data from dialog and back button not pressed
  150. } // if: not saving or haven't saved yet
  151. CBasePropertyPage::DoDataExchange(pDX);
  152. } //*** CPrintSpoolerParamsPage::DoDataExchange()
  153. /////////////////////////////////////////////////////////////////////////////
  154. //++
  155. //
  156. // CPrintSpoolerParamsPage::OnInitDialog
  157. //
  158. // Routine Description:
  159. // Handler for the WM_INITDIALOG message.
  160. //
  161. // Arguments:
  162. // None.
  163. //
  164. // Return Value:
  165. // TRUE We need the focus to be set for us.
  166. // FALSE We already set the focus to the proper control.
  167. //
  168. //--
  169. /////////////////////////////////////////////////////////////////////////////
  170. BOOL CPrintSpoolerParamsPage::OnInitDialog(void)
  171. {
  172. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  173. // Get a default value for the spool directory if it hasn't been set yet.
  174. if (m_strSpoolDir.GetLength() == 0)
  175. {
  176. ConstructDefaultDirectory(m_strSpoolDir, IDS_DEFAULT_SPOOL_DIR);
  177. }
  178. // Call the base class.
  179. CBasePropertyPage::OnInitDialog();
  180. // Set limits on the edit controls.
  181. m_editSpoolDir.SetLimitText(MAX_PATH);
  182. return TRUE; // return TRUE unless you set the focus to a control
  183. // EXCEPTION: OCX Property Pages should return FALSE
  184. } //*** CPrintSpoolerParamsPage::OnInitDialog()
  185. /////////////////////////////////////////////////////////////////////////////
  186. //++
  187. //
  188. // CPrintSpoolerParamsPage::OnSetActive
  189. //
  190. // Routine Description:
  191. // Handler for the PSN_SETACTIVE message.
  192. //
  193. // Arguments:
  194. // None.
  195. //
  196. // Return Value:
  197. // TRUE Page successfully initialized.
  198. // FALSE Page not initialized.
  199. //
  200. //--
  201. /////////////////////////////////////////////////////////////////////////////
  202. BOOL CPrintSpoolerParamsPage::OnSetActive(void)
  203. {
  204. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  205. // Enable/disable the Next/Finish button.
  206. if (BWizard())
  207. {
  208. if (m_strSpoolDir.GetLength() == 0)
  209. {
  210. EnableNext(FALSE);
  211. }
  212. else
  213. {
  214. EnableNext(TRUE);
  215. }
  216. } // if: enable/disable the Next button
  217. return CBasePropertyPage::OnSetActive();
  218. } //*** CPrintSpoolerParamsPage::OnSetActive()
  219. /////////////////////////////////////////////////////////////////////////////
  220. //++
  221. //
  222. // CPrintSpoolerParamsPage::BApplyChanges
  223. //
  224. // Routine Description:
  225. // Apply changes made on the page.
  226. //
  227. // Arguments:
  228. // None.
  229. //
  230. // Return Value:
  231. // TRUE Page successfully applied.
  232. // FALSE Error applying page.
  233. //
  234. //--
  235. /////////////////////////////////////////////////////////////////////////////
  236. BOOL CPrintSpoolerParamsPage::BApplyChanges(void)
  237. {
  238. BOOL bSuccess;
  239. CWaitCursor wc;
  240. // Convert the job completion timeout from seconds to milliseconds.
  241. m_nJobCompletionTimeout *= 1000;
  242. // Call the base class method.
  243. bSuccess = CBasePropertyPage::BApplyChanges();
  244. // Convert the job completion timeout back to seconds.
  245. if (bSuccess)
  246. m_nPrevJobCompletionTimeout = m_nJobCompletionTimeout;
  247. m_nJobCompletionTimeout /= 1000;
  248. return bSuccess;
  249. } //*** CPrintSpoolerParamsPage::BApplyChanges()
  250. /////////////////////////////////////////////////////////////////////////////
  251. //++
  252. //
  253. // CPrintSpoolerParamsPage::OnChangeSpoolDir
  254. //
  255. // Routine Description:
  256. // Handler for the EN_CHANGE message on the Spool Folder edit control.
  257. //
  258. // Arguments:
  259. // None.
  260. //
  261. // Return Value:
  262. // None.
  263. //
  264. //--
  265. /////////////////////////////////////////////////////////////////////////////
  266. void CPrintSpoolerParamsPage::OnChangeSpoolDir(void)
  267. {
  268. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  269. OnChangeCtrl();
  270. if (BWizard())
  271. {
  272. if (m_editSpoolDir.GetWindowTextLength() == 0)
  273. EnableNext(FALSE);
  274. else
  275. EnableNext(TRUE);
  276. } // if: in a wizard
  277. } //*** CPrintSpoolerParamsPage::OnChangeSpoolDir()