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.

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