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.

836 lines
14 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. All rights reserved.
  4. Module Name:
  5. prop.hxx
  6. Abstract:
  7. Printer properties header.
  8. Author:
  9. Albert Ting (AlbertT) 17-Aug-1995
  10. Revision History:
  11. --*/
  12. #ifndef _PRTPROP_HXX
  13. #define _PRTPROP_HXX
  14. /********************************************************************
  15. Forward references.
  16. ********************************************************************/
  17. class TPrinterPropertySheetManager;
  18. class TPrtShare;
  19. class TFindLocDlg;
  20. /********************************************************************
  21. Printer property sheet data.
  22. ********************************************************************/
  23. class TPrinterData : public MSingletonWin, public MRefCom {
  24. SIGNATURE( 'prtp' )
  25. SAFE_NEW
  26. public:
  27. enum EPrinterPropPages {
  28. kPropGeneral,
  29. kPropSharing,
  30. kPropPorts,
  31. kPropJobScheduling,
  32. kPropMax
  33. };
  34. enum EPublishState {
  35. kNoAction,
  36. kPublish,
  37. kUnPublish,
  38. kPublished,
  39. kNotPublished,
  40. kNoDsAvailable,
  41. kUnInitalized,
  42. };
  43. enum EDsAvailableState {
  44. kDsAvailable,
  45. kDsNotAvailable,
  46. kDsUnInitalized,
  47. };
  48. VAR( UINT, uStartPage );
  49. VAR( BOOL, bValid );
  50. VAR( BOOL, bNoAccess );
  51. VAR( BOOL, bErrorSaving );
  52. VAR( BOOL, bIsFaxDriver );
  53. VAR( BOOL, bHideSharingUI );
  54. VAR( BOOL, bGlobalDevMode );
  55. VAR( BOOL, bDriverPagesNotLoaded );
  56. VAR( BOOL, bApplyEnableState );
  57. VAR( BOOL, bPooledPrinting );
  58. VAR( BOOL, bDefaultPrinter );
  59. VAR( BOOL, bServerFullAccess );
  60. VAR( TString, strServerName );
  61. VAR( LPCTSTR, pszServerName );
  62. VAR( TString, strShareName );
  63. VAR( TString, strDriverName );
  64. VAR( TString, strComment );
  65. VAR( TString, strLocation );
  66. VAR( TString, strSheetName );
  67. VAR( TString, strCurrentPrinterName );
  68. VAR( TString, strPortName );
  69. VAR( TString, strSepFile );
  70. VAR( TString, strPrintProcessor );
  71. VAR( TString, strDatatype );
  72. VAR( TString, strStartPage );
  73. VAR( TString, strDriverEnv );
  74. VAR( TString, strDsPath );
  75. VAR( TString, strObjectGUID );
  76. VAR( HANDLE, hPrinter );
  77. VAR( CAutoHandleIcon, shLargeIcon );
  78. VAR( CAutoHandleIcon, shSmallIcon );
  79. VAR( DWORD, dwAttributes );
  80. VAR( DWORD, dwPriority );
  81. VAR( DWORD, dwStartTime );
  82. VAR( DWORD, dwUntilTime );
  83. VAR( DWORD, dwStatus );
  84. VAR( DWORD, dwAccess );
  85. VAR( DWORD, dwDriverVersion );
  86. VAR( DWORD, dwAction );
  87. VAR( UINT, uMaxActiveCount );
  88. VAR( UINT, uActiveCount );
  89. VAR( PDEVMODE, pDevMode );
  90. VAR( TPrinterPropertySheetManager *, pPrinterPropertySheetManager );
  91. LONG_PTR _hPages[kPropMax];
  92. HWND _hwndPages[kPropMax];
  93. HWND _hwndLastPageSelected;
  94. TPrinterData(
  95. IN LPCTSTR pszPrinterName,
  96. IN INT nCmdShow,
  97. IN LPCTSTR pszSheetName,
  98. IN DWORD dwSheetIndex,
  99. IN HWND hwnd,
  100. IN BOOL bModal,
  101. IN LPCTSTR pszDsPath = NULL
  102. );
  103. ~TPrinterData(
  104. VOID
  105. );
  106. BOOL
  107. bLoad(
  108. VOID
  109. );
  110. VOID
  111. vUnload(
  112. VOID
  113. );
  114. BOOL
  115. bSave(
  116. IN BOOL bUpdateDevMode = FALSE
  117. );
  118. BOOL
  119. bAdministrator(
  120. VOID
  121. );
  122. BOOL
  123. bSupportBidi(
  124. VOID
  125. );
  126. EPublishState
  127. ePrinterPublishState(
  128. TPrinterData::EPublishState eNewPublishState = EPublishState::kUnInitalized
  129. );
  130. BOOL
  131. bIsDsAvailable(
  132. VOID
  133. );
  134. BOOL
  135. bCheckForChange(
  136. IN UINT uLevel = -1
  137. );
  138. INT
  139. ComparePrinterName(
  140. IN LPCTSTR pszPrinterName1,
  141. IN LPCTSTR pszPrinterName2
  142. );
  143. private:
  144. VOID
  145. vRefZeroed(
  146. VOID
  147. );
  148. BOOL
  149. bDriverChangedGenPrinterName(
  150. TString *pstrNewName
  151. ) const;
  152. BOOL
  153. bUpdateGlobalDevMode(
  154. VOID
  155. );
  156. BOOL
  157. bUpdatePerUserDevMode(
  158. VOID
  159. );
  160. VOID
  161. vGetSpecialInformation(
  162. VOID
  163. );
  164. LPCTSTR
  165. pGetAdjustedPrinterName(
  166. IN LPCTSTR pszPrinterName,
  167. OUT TString &strTempPrinterName
  168. ) const;
  169. //
  170. // Prevent copying and assignment.
  171. //
  172. TPrinterData(
  173. const TPrinterData &
  174. );
  175. TPrinterData &
  176. operator =(
  177. const TPrinterData &
  178. );
  179. //
  180. // Printer Info data class.
  181. //
  182. class TPrinterInfo {
  183. SIGNATURE( 'prif' )
  184. public:
  185. TPrinterInfo(
  186. VOID
  187. );
  188. ~TPrinterInfo(
  189. VOID
  190. );
  191. BOOL
  192. bUpdate(
  193. IN PPRINTER_INFO_2 pInfo
  194. );
  195. BOOL
  196. bUpdate(
  197. IN PPRINTER_INFO_7 pInfo
  198. );
  199. TString _strServerName;
  200. TString _strPrinterName;
  201. TString _strShareName;
  202. TString _strDriverName;
  203. TString _strComment;
  204. TString _strLocation;
  205. TString _strPortName;
  206. TString _strSepFile;
  207. TString _strPrintProcessor;
  208. TString _strDatatype;
  209. DWORD _dwAttributes;
  210. DWORD _dwPriority;
  211. DWORD _dwStartTime;
  212. DWORD _dwUntilTime;
  213. BOOL _bPooledPrinting;
  214. TString _strObjectGUID;
  215. DWORD _dwAction;
  216. private:
  217. //
  218. // Prevent copying and assignment.
  219. //
  220. TPrinterInfo(
  221. const TPrinterInfo &
  222. );
  223. TPrinterInfo &
  224. operator =(
  225. const TPrinterInfo &
  226. );
  227. };
  228. EPublishState _ePrinterPublishState;
  229. EDsAvailableState _eDsAvailableState;
  230. TPrinterInfo _PrinterInfo;
  231. };
  232. /********************************************************************
  233. PrinterProp.
  234. Base class for printer property sheets. This class should not
  235. not contain any information/services that is not generic to all
  236. derived classes.
  237. The printer property sheets should inherit from this class.
  238. bHandleMessage (which is not overriden here) should be
  239. defined in derived classes.
  240. ********************************************************************/
  241. class TPrinterProp : public MGenericProp {
  242. SIGNATURE( 'prpr' )
  243. ALWAYS_VALID
  244. SAFE_NEW
  245. public:
  246. //
  247. // Serves as the thread start routine.
  248. //
  249. static
  250. INT
  251. iPrinterPropPagesProc(
  252. TPrinterData* pPrinterData
  253. );
  254. protected:
  255. VAR( TPrinterData*, pPrinterData );
  256. TPrinterProp(
  257. TPrinterData* pPrinterData
  258. );
  259. TPrinterProp(
  260. const TPrinterProp &
  261. );
  262. TPrinterProp &
  263. operator = (
  264. const TPrinterProp &
  265. );
  266. VOID
  267. vSetIcon(
  268. VOID
  269. );
  270. VOID
  271. vSetIconName(
  272. VOID
  273. );
  274. VOID
  275. vReloadPages(
  276. VOID
  277. );
  278. VOID
  279. vCancelToClose(
  280. VOID
  281. );
  282. VOID
  283. vSetApplyState(
  284. IN BOOL bNewApplyState
  285. );
  286. virtual
  287. BOOL
  288. _bHandleMessage(
  289. IN UINT uMsg,
  290. IN WPARAM wParam,
  291. IN LPARAM lParam
  292. ) = 0;
  293. private:
  294. BOOL
  295. bHandleMessage(
  296. IN UINT uMsg,
  297. IN WPARAM wParam,
  298. IN LPARAM lParam
  299. );
  300. BOOL
  301. bHandle_InitDialog(
  302. IN WPARAM wParam,
  303. IN LPARAM lParam
  304. );
  305. BOOL
  306. bHandle_Notify(
  307. IN WPARAM wParam,
  308. IN LPARAM lParam
  309. );
  310. BOOL
  311. bHandle_SettingChange(
  312. IN WPARAM wParam,
  313. IN LPARAM lParam
  314. );
  315. VOID
  316. vPropSheetChangedAllPages(
  317. VOID
  318. );
  319. VOID
  320. vPropSheetUnChangedAllPages(
  321. VOID
  322. );
  323. VOID
  324. vNotifyActivePagesToRefresh(
  325. VOID
  326. );
  327. VOID
  328. vApplyChanges(
  329. VOID
  330. );
  331. };
  332. /********************************************************************
  333. General printer property page.
  334. ********************************************************************/
  335. class TPrinterGeneral : public TPrinterProp {
  336. SIGNATURE( 'gepr' )
  337. SAFE_NEW
  338. public:
  339. TPrinterGeneral(
  340. TPrinterData* pPrinterData
  341. );
  342. ~TPrinterGeneral(
  343. VOID
  344. );
  345. BOOL
  346. bValid(
  347. VOID
  348. );
  349. private:
  350. /********************************************************************
  351. Virtual override.
  352. ********************************************************************/
  353. BOOL
  354. _bHandleMessage(
  355. IN UINT uMsg,
  356. IN WPARAM wParam,
  357. IN LPARAM lParam
  358. );
  359. BOOL
  360. bSetUI(
  361. VOID
  362. );
  363. VOID
  364. vReadUI(
  365. VOID
  366. );
  367. VOID
  368. vHandleBrowseLocation(
  369. VOID
  370. );
  371. VOID
  372. vHandleDocumentDefaults(
  373. IN WPARAM wParam,
  374. IN LPARAM lParam
  375. );
  376. VOID
  377. vReloadFeaturesInformation(
  378. VOID
  379. );
  380. VOID
  381. vSetActive(
  382. VOID
  383. );
  384. VOID
  385. vKillActive(
  386. VOID
  387. );
  388. VOID
  389. vCheckForSharedMasqPrinter(
  390. VOID
  391. );
  392. BOOL _bSetUIDone;
  393. TFindLocDlg *_pLocationDlg;
  394. CMultilineEditBug m_wndComment;
  395. };
  396. /********************************************************************
  397. Ports Property Page.
  398. ********************************************************************/
  399. class TPrinterPorts : public TPrinterProp {
  400. SIGNATURE( 'popr' )
  401. SAFE_NEW
  402. public:
  403. TPrinterPorts(
  404. TPrinterData *pPrinterData
  405. );
  406. ~TPrinterPorts(
  407. VOID
  408. );
  409. BOOL
  410. bValid(
  411. VOID
  412. );
  413. private:
  414. TPortsLV _PortsLV;
  415. BOOL _bAdminFlag;
  416. /********************************************************************
  417. Virtual override.
  418. ********************************************************************/
  419. BOOL
  420. _bHandleMessage(
  421. UINT uMsg,
  422. WPARAM wParam,
  423. LPARAM lParam
  424. );
  425. BOOL
  426. bSetUI(
  427. VOID
  428. );
  429. VOID
  430. vReadUI(
  431. VOID
  432. );
  433. VOID
  434. vSetActive(
  435. VOID
  436. );
  437. BOOL
  438. bKillActive(
  439. VOID
  440. );
  441. };
  442. /********************************************************************
  443. Job Scheduling Property Page.
  444. ********************************************************************/
  445. class TPrinterJobScheduling : public TPrinterProp {
  446. SIGNATURE( 'jspr' )
  447. SAFE_NEW
  448. public:
  449. TPrinterJobScheduling(
  450. TPrinterData *pPrinterData
  451. );
  452. ~TPrinterJobScheduling(
  453. VOID
  454. );
  455. BOOL
  456. bValid(
  457. VOID
  458. );
  459. private:
  460. enum _CONSTANTS {
  461. kPriorityMin = 1,
  462. kPriorityMax = 99,
  463. };
  464. BOOL _bSetUIDone;
  465. /********************************************************************
  466. Virtual override.
  467. ********************************************************************/
  468. BOOL
  469. _bHandleMessage(
  470. IN UINT uMsg,
  471. IN WPARAM wParam,
  472. IN LPARAM lParam
  473. );
  474. BOOL
  475. bSetUI(
  476. VOID
  477. );
  478. VOID
  479. vReadUI(
  480. VOID
  481. );
  482. VOID
  483. vEnableAvailable(
  484. BOOL bEnable
  485. );
  486. VOID
  487. vUpdatePriorityNumber(
  488. DWORD dwPriority
  489. );
  490. BOOL
  491. bSetStartAndUntilTime(
  492. VOID
  493. );
  494. VOID
  495. vSetActive(
  496. VOID
  497. );
  498. VOID
  499. vSeparatorPage(
  500. VOID
  501. );
  502. VOID
  503. vPrintProcessor(
  504. VOID
  505. );
  506. VOID
  507. vHandleGlobalDocumentDefaults(
  508. IN WPARAM wParam,
  509. IN LPARAM lParam
  510. );
  511. BOOL
  512. bFillAndSelectDrivers(
  513. VOID
  514. );
  515. VOID
  516. vHandleNewDriver(
  517. IN WPARAM wParam,
  518. IN LPARAM lParam
  519. );
  520. };
  521. /********************************************************************
  522. Sharing Property Page.
  523. ********************************************************************/
  524. class TPrinterSharing : public TPrinterProp {
  525. SIGNATURE( 'sepr' )
  526. SAFE_NEW
  527. public:
  528. TPrinterSharing(
  529. TPrinterData *pPrinterData
  530. );
  531. ~TPrinterSharing(
  532. VOID
  533. );
  534. BOOL
  535. bValid(
  536. VOID
  537. );
  538. private:
  539. TPrtShare *_pPrtShare;
  540. BOOL _bHideListed;
  541. BOOL _bSetUIDone;
  542. BOOL _bAcceptInvalidDosShareName;
  543. BOOL _bDefaultPublishState;
  544. BOOL _bSharingEnabled;
  545. TString _strPendingText;
  546. TString _strShareName;
  547. //
  548. // Copying and assignment are not defined.
  549. //
  550. TPrinterSharing(
  551. const TPrinterSharing &rhs
  552. );
  553. TPrinterSharing &
  554. operator =(
  555. const TPrinterSharing &rhs
  556. );
  557. VOID
  558. vSetActive(
  559. VOID
  560. );
  561. VOID
  562. vSharePrinter(
  563. VOID
  564. );
  565. VOID
  566. vSetDefaultShareName(
  567. VOID
  568. );
  569. VOID
  570. vUnsharePrinter(
  571. VOID
  572. );
  573. BOOL
  574. bKillActive(
  575. VOID
  576. );
  577. VOID
  578. vAdditionalDrivers(
  579. IN WPARAM wParam,
  580. IN LPARAM lParam
  581. );
  582. /********************************************************************
  583. Virtual override.
  584. ********************************************************************/
  585. BOOL
  586. _bHandleMessage(
  587. UINT uMsg,
  588. WPARAM wParam,
  589. LPARAM lParam
  590. );
  591. BOOL
  592. bSetUI(
  593. VOID
  594. );
  595. VOID
  596. vReadUI(
  597. VOID
  598. );
  599. };
  600. /********************************************************************
  601. Global scoped functions.
  602. ********************************************************************/
  603. VOID
  604. vPrinterPropPages(
  605. IN HWND hwnd,
  606. IN LPCTSTR pszPrinterName,
  607. IN INT nCmdShow,
  608. IN LPARAM lParam
  609. );
  610. DWORD
  611. dwPrinterPropPages(
  612. IN HWND hwnd,
  613. IN IDataObject *pDataObject,
  614. IN PBOOL pbDisplayed
  615. );
  616. DWORD
  617. dwPrinterPropPages(
  618. IN HWND hwnd,
  619. IN LPCTSTR pszDsPath,
  620. IN PBOOL pbDisplayed
  621. );
  622. DWORD
  623. dwPrinterPropPagesInternal(
  624. IN HWND hwnd,
  625. IN LPCTSTR pszPrinterName,
  626. IN LPCTSTR pszSheetName,
  627. IN DWORD dwSheetIndex,
  628. IN INT nCmdShow,
  629. IN BOOL bModal,
  630. IN LPCTSTR pszDsPath
  631. );
  632. #endif // def _PRTPROP_HXX