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.

1128 lines
23 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. ptrprop.c
  5. Abstract:
  6. This module contains PrinterProperties() API entry and it's related
  7. functions
  8. Author:
  9. 06-Dec-1993 Mon 10:30:43 created
  10. [Environment:]
  11. GDI Device Driver - Plotter.
  12. [Notes:]
  13. Revision History:
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #define DBG_PLOTFILENAME DbgPtrProp
  18. extern HMODULE hPlotUIModule;
  19. #define DBG_DEVHTINFO 0x00000001
  20. #define DBG_PP_FORM 0x00000002
  21. #define DBG_EXTRA_DATA 0x00000004
  22. #define DBG_CHK_PENSET_BUTTON 0x00000008
  23. DEFINE_DBGVAR(0);
  24. //
  25. // Form To Tray Assignment:
  26. // Roll Paper Feeder: <XYZ>
  27. // Manual Feed Method:
  28. // Print Form Options:
  29. // [] Auto. Rotate To Save Roll Paper:
  30. // [] Print Smaller Paper Size:
  31. // Halftone Setup...
  32. // Installed Pen Set: Pen Set #1
  33. // Pen Setup:
  34. // Installed: Pen Set #1
  35. // Pen Set #1:
  36. // Pen Number 1:
  37. // Pen Number 2:
  38. // Pen Number 3:
  39. // Pen Number 4:
  40. // Pen Number 5:
  41. // Pen Number 6:
  42. // Pen Number 7:
  43. // Pen Number 8:
  44. // Pen Number 9:
  45. // Pen Number 10:
  46. // Pen Number 11:
  47. // Pen Set #2;
  48. // Pen Set #3:
  49. // Pen Set #4: <Currently Installed>
  50. // Pen Set #5:
  51. // Pen Set #6:
  52. // Pen Set #7:
  53. // Pen Set #8:
  54. //
  55. OPDATA OPPenSet = { 0, IDS_PENSET_FIRST, IDI_PENSET, 0, 0, 0 };
  56. OPDATA OPAutoRotate[] = {
  57. { 0, IDS_CPSUI_NO, IDI_AUTO_ROTATE_NO, 0, 0, 0 },
  58. { 0, IDS_CPSUI_YES, IDI_AUTO_ROTATE_YES, 0, 0, 0 }
  59. };
  60. OPDATA OPPrintSmallerPaper[] = {
  61. { 0, IDS_CPSUI_NO, IDI_PRINT_SMALLER_PAPER_NO, 0, 0, 0 },
  62. { 0, IDS_CPSUI_YES, IDI_PRINT_SMALLER_PAPER_YES, 0, 0, 0 }
  63. };
  64. OPDATA OPManualFeed[] = {
  65. { 0, IDS_MANUAL_CX, IDI_MANUAL_CX, 0, 0, 0 },
  66. { 0, IDS_MANUAL_CY, IDI_MANUAL_CY, 0, 0, 0 }
  67. };
  68. OPDATA OPHTSetup = {
  69. 0,
  70. PI_OFF(ExtraData) + sizeof(DEVHTINFO),
  71. IDI_CPSUI_HALFTONE_SETUP,
  72. PUSHBUTTON_TYPE_HTSETUP,
  73. 0,
  74. 0
  75. };
  76. OIDATA PPOIData[] = {
  77. {
  78. ODF_PEN_RASTER,
  79. 0,
  80. OI_LEVEL_1,
  81. PP_FORMTRAY_ASSIGN,
  82. TVOT_NONE,
  83. IDS_CPSUI_FORMTRAYASSIGN,
  84. IDI_CPSUI_FORMTRAYASSIGN,
  85. IDH_FORMTRAYASSIGN,
  86. 0,
  87. NULL
  88. },
  89. {
  90. ODF_RASTER | ODF_ROLLFEED | ODF_CALLBACK | ODF_CALLCREATEOI,
  91. 0,
  92. OI_LEVEL_2,
  93. PP_INSTALLED_FORM,
  94. TVOT_LISTBOX,
  95. IDS_ROLLFEED,
  96. OTS_LBCB_SORT,
  97. IDH_FORM_ROLL_FEEDER,
  98. 0,
  99. (POPDATA)CreateFormOI
  100. },
  101. {
  102. ODF_RASTER | ODF_MANUAL_FEED | ODF_CALLBACK | ODF_CALLCREATEOI,
  103. 0,
  104. OI_LEVEL_2,
  105. PP_INSTALLED_FORM,
  106. TVOT_LISTBOX,
  107. IDS_MANUAL_FEEDER,
  108. OTS_LBCB_SORT,
  109. IDH_FORM_MANUAL_FEEDER,
  110. 0,
  111. (POPDATA)CreateFormOI
  112. },
  113. {
  114. ODF_PEN | ODF_CALLBACK | ODF_CALLCREATEOI,
  115. 0,
  116. OI_LEVEL_2,
  117. PP_INSTALLED_FORM,
  118. TVOT_LISTBOX,
  119. IDS_MAINFEED,
  120. OTS_LBCB_SORT,
  121. IDH_FORM_MAIN_FEEDER,
  122. 0,
  123. (POPDATA)CreateFormOI
  124. },
  125. {
  126. ODF_PEN_RASTER | ODF_CALLBACK | ODF_NO_PAPERTRAY,
  127. 0,
  128. OI_LEVEL_3,
  129. PP_MANUAL_FEED_METHOD,
  130. TVOT_2STATES,
  131. IDS_MANUAL_FEED_METHOD,
  132. 0,
  133. IDH_MANUAL_FEED_METHOD,
  134. COUNT_ARRAY(OPManualFeed),
  135. OPManualFeed
  136. },
  137. {
  138. ODF_PEN_RASTER,
  139. 0,
  140. OI_LEVEL_1,
  141. PP_PRINT_FORM_OPTIONS,
  142. TVOT_NONE,
  143. IDS_PRINT_FORM_OPTIONS,
  144. IDI_CPSUI_GENERIC_OPTION,
  145. IDH_PRINT_FORM_OPTIONS,
  146. 0,
  147. NULL
  148. },
  149. {
  150. ODF_PEN_RASTER | ODF_ROLLFEED,
  151. 0,
  152. OI_LEVEL_2,
  153. PP_AUTO_ROTATE,
  154. TVOT_2STATES,
  155. IDS_AUTO_ROTATE,
  156. 0,
  157. IDH_AUTO_ROTATE,
  158. 2,
  159. OPAutoRotate
  160. },
  161. {
  162. ODF_PEN_RASTER,
  163. 0,
  164. OI_LEVEL_2,
  165. PP_PRINT_SMALLER_PAPER,
  166. TVOT_2STATES,
  167. IDS_PRINT_SAMLLER_PAPER,
  168. 0,
  169. IDH_PRINT_SMALLER_PAPER,
  170. 2,
  171. OPPrintSmallerPaper
  172. },
  173. {
  174. ODF_RASTER,
  175. 0,
  176. OI_LEVEL_1,
  177. PP_HT_SETUP,
  178. TVOT_PUSHBUTTON,
  179. IDS_CPSUI_HALFTONE_SETUP,
  180. 0,
  181. IDH_HALFTONE_SETUP,
  182. 1,
  183. &OPHTSetup
  184. },
  185. {
  186. ODF_PEN | ODF_INC_IDSNAME | ODF_NO_INC_POPDATA,
  187. 0,
  188. OI_LEVEL_1,
  189. PP_INSTALLED_PENSET,
  190. TVOT_LISTBOX,
  191. IDS_INSTALLED_PENSET,
  192. OTS_LBCB_SORT,
  193. IDH_INSTALLED_PENSET,
  194. PRK_MAX_PENDATA_SET,
  195. &OPPenSet
  196. },
  197. {
  198. ODF_PEN | ODF_COLLAPSE | ODF_CALLCREATEOI,
  199. 0,
  200. OI_LEVEL_1,
  201. PP_PEN_SETUP,
  202. TVOT_NONE,
  203. IDS_PEN_SETUP,
  204. IDI_PEN_SETUP,
  205. IDH_PEN_SETUP,
  206. 1,
  207. (POPDATA)CreatePenSetupOI
  208. }
  209. };
  210. DWORD
  211. CheckPenSetButton(
  212. PPRINTERINFO pPI,
  213. DWORD Action
  214. )
  215. /*++
  216. Routine Description:
  217. Arguments:
  218. Return Value:
  219. Author:
  220. 30-Nov-1995 Thu 16:41:05 created
  221. Revision History:
  222. --*/
  223. {
  224. POPTITEM pOptItem = pPI->pOptItem;
  225. POPTITEM pEndItem = pOptItem + pPI->cOptItem;
  226. PLOTDBG(DBG_CHK_PENSET_BUTTON,
  227. ("CheckPenSetButton: pFirst=%08lx, pLast=%08lx, Count=%ld",
  228. pOptItem, pEndItem, pPI->cOptItem));
  229. while (pOptItem < pEndItem) {
  230. if (pOptItem->DMPubID == PP_PENSET) {
  231. PPENDATA pPD;
  232. POPTITEM pOI;
  233. DWORD Flags;
  234. UINT i;
  235. pOI = pOptItem + 1;
  236. pPD = (PPENDATA)pPI->pPlotGPC->Pens.pData;
  237. i = (UINT)pPI->pPlotGPC->MaxPens;
  238. Flags = (OPTIF_EXT_DISABLED | OPTIF_EXT_HIDE);
  239. while (i--) {
  240. if (pOI->Sel != pPD->ColorIdx) {
  241. Flags &= ~(OPTIF_EXT_DISABLED | OPTIF_EXT_HIDE);
  242. }
  243. pOI++;
  244. pPD++;
  245. }
  246. if ((Flags & (OPTIF_EXT_DISABLED | OPTIF_EXT_HIDE)) !=
  247. (pOptItem->Flags & (OPTIF_EXT_DISABLED | OPTIF_EXT_HIDE))) {
  248. Action = CPSUICB_ACTION_REINIT_ITEMS;
  249. pOptItem->Flags &= ~(OPTIF_EXT_DISABLED | OPTIF_EXT_HIDE);
  250. pOptItem->Flags |= (Flags | OPTIF_CHANGED);
  251. }
  252. pOptItem = pOI;
  253. } else {
  254. pOptItem++;
  255. }
  256. }
  257. return(Action);
  258. }
  259. DWORD
  260. CheckInstalledForm(
  261. PPRINTERINFO pPI,
  262. DWORD Action
  263. )
  264. /*++
  265. Routine Description:
  266. Arguments:
  267. Return Value:
  268. Author:
  269. 30-May-1996 Thu 12:34:00 created
  270. Revision History:
  271. --*/
  272. {
  273. POPTITEM pOIForm;
  274. POPTITEM pOIFeed;
  275. POPTITEM pOITemp;
  276. POPTPARAM pOP;
  277. FORM_INFO_1 *pFI1;
  278. DWORD MFFlags;
  279. DWORD PSPFlags;
  280. DWORD ARFlags;
  281. if ((pOIForm = FindOptItem(pPI->pOptItem,
  282. pPI->cOptItem,
  283. PP_INSTALLED_FORM)) &&
  284. (pOIFeed = FindOptItem(pPI->pOptItem,
  285. pPI->cOptItem,
  286. PP_MANUAL_FEED_METHOD))) {
  287. pOP = pOIForm->pOptType->pOptParam + pOIForm->Sel;
  288. switch (pOP->Style) {
  289. case FS_ROLLPAPER:
  290. case FS_TRAYPAPER:
  291. MFFlags = OPTIF_DISABLED;
  292. break;
  293. default:
  294. pFI1 = pPI->pFI1Base + pOP->lParam;
  295. if ((pFI1->Size.cx > pPI->pPlotGPC->DeviceSize.cx) ||
  296. (pFI1->Size.cy > pPI->pPlotGPC->DeviceSize.cx)) {
  297. MFFlags = (OPTIF_OVERLAY_STOP_ICON | OPTIF_DISABLED);
  298. } else {
  299. MFFlags = 0;
  300. }
  301. break;
  302. }
  303. if ((pOIFeed->Flags & (OPTIF_OVERLAY_STOP_ICON |
  304. OPTIF_DISABLED)) != MFFlags) {
  305. pOIFeed->Flags &= ~(OPTIF_OVERLAY_STOP_ICON | OPTIF_DISABLED);
  306. pOIFeed->Flags |= (MFFlags | OPTIF_CHANGED);
  307. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  308. }
  309. if (pOP->Style & FS_ROLLPAPER) {
  310. ARFlags = 0;
  311. PSPFlags = OPTIF_DISABLED;
  312. } else {
  313. ARFlags = OPTIF_DISABLED;
  314. PSPFlags = 0;
  315. }
  316. if ((pOITemp = FindOptItem(pPI->pOptItem,
  317. pPI->cOptItem,
  318. PP_PRINT_SMALLER_PAPER)) &&
  319. ((pOITemp->Flags & OPTIF_DISABLED) != PSPFlags)) {
  320. pOITemp->Flags &= ~OPTIF_DISABLED;
  321. pOITemp->Flags |= (PSPFlags | OPTIF_CHANGED);
  322. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  323. }
  324. if ((pOITemp = FindOptItem(pPI->pOptItem,
  325. pPI->cOptItem,
  326. PP_AUTO_ROTATE)) &&
  327. ((pOITemp->Flags & OPTIF_DISABLED) != ARFlags)) {
  328. pOITemp->Flags &= ~OPTIF_DISABLED;
  329. pOITemp->Flags |= (ARFlags | OPTIF_CHANGED);
  330. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  331. }
  332. }
  333. return(Action);
  334. }
  335. UINT
  336. SetupPPOptItems(
  337. PPRINTERINFO pPI
  338. )
  339. /*++
  340. Routine Description:
  341. Arguments:
  342. Return Value:
  343. Author:
  344. 16-Nov-1995 Thu 14:15:25 created
  345. Revision History:
  346. --*/
  347. {
  348. POPTITEM pOIForm;
  349. POPTITEM pOptItem;
  350. POPTITEM pOI;
  351. POIDATA pOIData;
  352. WORD PPFlags;
  353. DWORD Flags;
  354. DWORD ODFlags;
  355. UINT i;
  356. pOI =
  357. pOptItem = pPI->pOptItem;
  358. pOIData = PPOIData;
  359. i = (UINT)COUNT_ARRAY(PPOIData);
  360. Flags = pPI->pPlotGPC->Flags;
  361. PPFlags = pPI->PPData.Flags;
  362. ODFlags = (Flags & PLOTF_RASTER) ? ODF_RASTER : ODF_PEN;
  363. while (i--) {
  364. DWORD OIFlags = pOIData->Flags;
  365. if ((!(OIFlags & ODFlags)) ||
  366. ((OIFlags & ODF_MANUAL_FEED) &&
  367. (Flags & (PLOTF_ROLLFEED | PLOTF_PAPERTRAY))) ||
  368. ((OIFlags & ODF_ROLLFEED) && (!(Flags & PLOTF_ROLLFEED))) ||
  369. ((OIFlags & ODF_NO_PAPERTRAY) && (Flags & PLOTF_PAPERTRAY)) ||
  370. ((OIFlags & ODF_COLOR) && (!(Flags & PLOTF_COLOR)))) {
  371. //
  372. // Nothing to do here
  373. //
  374. NULL;
  375. } else if (OIFlags & ODF_CALLCREATEOI) {
  376. pOI += pOIData->pfnCreateOI(pPI,
  377. (LPVOID)((pOptItem) ? pOI : NULL),
  378. pOIData);
  379. } else if (pOptItem) {
  380. if (CreateOPTTYPE(pPI, pOI, pOIData, pOIData->cOPData, NULL)) {
  381. switch (pOI->DMPubID) {
  382. case PP_MANUAL_FEED_METHOD:
  383. pOI->Sel = (LONG)((PPFlags & PPF_MANUAL_FEED_CX) ? 0 : 1);
  384. break;
  385. case PP_AUTO_ROTATE:
  386. pOI->Sel = (LONG)((PPFlags & PPF_AUTO_ROTATE) ? 1 : 0);
  387. break;
  388. case PP_PRINT_SMALLER_PAPER:
  389. pOI->Sel = (LONG)((PPFlags & PPF_SMALLER_FORM) ? 1 : 0);
  390. break;
  391. case PP_INSTALLED_PENSET:
  392. pOI->Sel = (LONG)pPI->IdxPenSet;
  393. break;
  394. }
  395. pOI++;
  396. }
  397. } else {
  398. pOI++;
  399. }
  400. pOIData++;
  401. }
  402. if ((i = (UINT)(pOI - pOptItem)) && (!pOptItem)) {
  403. if (pPI->pOptItem = (POPTITEM)LocalAlloc(LPTR, sizeof(OPTITEM) * i)) {
  404. pPI->cOptItem = (WORD)i;
  405. //
  406. // Call myself second time to really create it
  407. //
  408. SetupPPOptItems(pPI);
  409. CheckInstalledForm(pPI, 0);
  410. CheckPenSetButton(pPI, 0);
  411. } else {
  412. i = 0;
  413. PLOTERR(("GetPPpOptItem(): LocalAlloc(%ld) failed",
  414. sizeof(OPTITEM) * i));
  415. }
  416. }
  417. return(i);
  418. }
  419. VOID
  420. SavePPOptItems(
  421. PPRINTERINFO pPI
  422. )
  423. /*++
  424. Routine Description:
  425. This function save all the device options back to registry if one changed
  426. and has a update permission
  427. Arguments:
  428. pPI - Pointer to the PRINTERINFO
  429. Return Value:
  430. VOID
  431. Author:
  432. 06-Nov-1995 Mon 18:05:16 created
  433. Revision History:
  434. --*/
  435. {
  436. POPTITEM pOptItem;
  437. POPTITEM pLastItem;
  438. PDEVHTINFO pAdjHTInfo;
  439. PCOLORINFO pCI;
  440. LPDWORD pHTPatSize;
  441. LPDWORD pDevPelsDPI;
  442. PPAPERINFO pCurPaper;
  443. LPBYTE pIdxPen;
  444. WORD PPFlags;
  445. BYTE DMPubID;
  446. pCI = NULL;
  447. pHTPatSize = NULL;
  448. pDevPelsDPI = NULL;
  449. pCurPaper = NULL;
  450. pIdxPen = NULL;
  451. if (!(pPI->Flags & PIF_UPDATE_PERMISSION)) {
  452. return;
  453. }
  454. pOptItem = pPI->pOptItem;
  455. pLastItem = pOptItem + pPI->cOptItem - 1;
  456. while (pOptItem <= pLastItem) {
  457. if ((DMPubID = pOptItem->DMPubID) == PP_PEN_SETUP) {
  458. pOptItem = SavePenSet(pPI, pOptItem);
  459. } else {
  460. if (pOptItem->Flags & OPTIF_CHANGEONCE) {
  461. switch (DMPubID) {
  462. case PP_INSTALLED_FORM:
  463. if (GetFormSelect(pPI, pOptItem)) {
  464. pCurPaper = &(pPI->CurPaper);
  465. }
  466. break;
  467. case PP_MANUAL_FEED_METHOD:
  468. if (pOptItem->Sel) {
  469. pPI->PPData.Flags &= ~PPF_MANUAL_FEED_CX;
  470. } else {
  471. pPI->PPData.Flags |= PPF_MANUAL_FEED_CX;
  472. }
  473. break;
  474. case PP_AUTO_ROTATE:
  475. if (pOptItem->Sel) {
  476. pPI->PPData.Flags |= PPF_AUTO_ROTATE;
  477. } else {
  478. pPI->PPData.Flags &= ~PPF_AUTO_ROTATE;
  479. }
  480. break;
  481. case PP_PRINT_SMALLER_PAPER:
  482. if (pOptItem->Sel) {
  483. pPI->PPData.Flags |= PPF_SMALLER_FORM;
  484. } else {
  485. pPI->PPData.Flags &= ~PPF_SMALLER_FORM;
  486. }
  487. break;
  488. case PP_HT_SETUP:
  489. pAdjHTInfo = PI_PADJHTINFO(pPI);
  490. pCI = &(pAdjHTInfo->ColorInfo);
  491. pDevPelsDPI = &(pAdjHTInfo->DevPelsDPI);
  492. pHTPatSize = &(pAdjHTInfo->HTPatternSize);
  493. break;
  494. case PP_INSTALLED_PENSET:
  495. pPI->IdxPenSet = (BYTE)pOptItem->Sel;
  496. pIdxPen = (LPBYTE)&(pPI->IdxPenSet);
  497. break;
  498. }
  499. }
  500. pOptItem++;
  501. }
  502. }
  503. if (!SaveToRegistry(pPI->hPrinter,
  504. pCI,
  505. pDevPelsDPI,
  506. pHTPatSize,
  507. pCurPaper,
  508. &(pPI->PPData),
  509. pIdxPen,
  510. 0,
  511. NULL)) {
  512. PlotUIMsgBox(NULL, IDS_PP_NO_SAVE, MB_ICONSTOP | MB_OK);
  513. }
  514. }
  515. CPSUICALLBACK
  516. PPCallBack(
  517. PCPSUICBPARAM pCPSUICBParam
  518. )
  519. /*++
  520. Routine Description:
  521. This is the callback function from the common property sheet UI
  522. Arguments:
  523. pCPSUICBParam - Pointer to the CPSUICBPARAM data structure to describe
  524. the nature of the callback
  525. Return Value:
  526. LONG
  527. Author:
  528. 07-Nov-1995 Tue 15:15:02 created
  529. Revision History:
  530. --*/
  531. {
  532. POPTITEM pCurItem = pCPSUICBParam->pCurItem;
  533. POPTITEM pItem;
  534. PPRINTERINFO pPI = (PPRINTERINFO)pCPSUICBParam->UserData;
  535. POPTPARAM pOP;
  536. DWORD Flags;
  537. UINT i;
  538. WORD Reason = pCPSUICBParam->Reason;
  539. LONG Action = CPSUICB_ACTION_NONE;
  540. if (Reason == CPSUICB_REASON_APPLYNOW) {
  541. PRINTER_INFO_7 PI7;
  542. SavePPOptItems(pPI);
  543. pCPSUICBParam->Result = CPSUI_OK;
  544. Action = CPSUICB_ACTION_ITEMS_APPLIED;
  545. PI7.pszObjectGUID = NULL;
  546. PI7.dwAction = DSPRINT_UPDATE;
  547. SetPrinter(pPI->hPrinter, 7, (LPBYTE)&PI7, 0);
  548. } else if (Reason == CPSUICB_REASON_ITEMS_REVERTED) {
  549. Action = CheckInstalledForm(pPI, Action);
  550. Action = CheckPenSetButton(pPI, Action);
  551. } else {
  552. switch (pCurItem->DMPubID) {
  553. case PP_PENSET:
  554. if ((Reason == CPSUICB_REASON_EXTPUSH) ||
  555. (Reason == CPSUICB_REASON_OPTITEM_SETFOCUS)) {
  556. PPENDATA pPD;
  557. pPI = (PPRINTERINFO)pCPSUICBParam->UserData;
  558. pPD = (PPENDATA)pPI->pPlotGPC->Pens.pData;
  559. i = (UINT)pPI->pPlotGPC->MaxPens;
  560. pItem = pCurItem++;
  561. if (Reason == CPSUICB_REASON_EXTPUSH) {
  562. while (i--) {
  563. pCurItem->Sel = pPD->ColorIdx;
  564. pCurItem->Flags |= OPTIF_CHANGED;
  565. pCurItem++;
  566. pPD++;
  567. }
  568. pItem->Flags |= (OPTIF_EXT_DISABLED |
  569. OPTIF_EXT_HIDE |
  570. OPTIF_CHANGED);
  571. Action = CPSUICB_ACTION_REINIT_ITEMS;
  572. } else {
  573. Action = CheckPenSetButton(pPI, Action);
  574. }
  575. }
  576. break;
  577. case PP_INSTALLED_FORM:
  578. if ((Reason == CPSUICB_REASON_SEL_CHANGED) ||
  579. (Reason == CPSUICB_REASON_OPTITEM_SETFOCUS)) {
  580. Action = CheckInstalledForm(pPI, Action);
  581. }
  582. break;
  583. default:
  584. break;
  585. }
  586. }
  587. return(Action);
  588. }
  589. LONG
  590. DrvDevicePropertySheets(
  591. PPROPSHEETUI_INFO pPSUIInfo,
  592. LPARAM lParam
  593. )
  594. /*++
  595. Routine Description:
  596. Show document property dialog box and update the output DEVMODE
  597. Arguments:
  598. pPSUIInfo - Pointer to the PROPSHEETUI_INFO data structure
  599. lParam - LPARAM for this call, it is a pointer to the
  600. DEVICEPROPERTYHEADER
  601. Return Value:
  602. LONG, 1=successful, 0=failed.
  603. Author:
  604. 02-Feb-1996 Fri 10:47:42 created
  605. Revision History:
  606. --*/
  607. {
  608. PDEVICEPROPERTYHEADER pDPHdr;
  609. PPRINTERINFO pPI;
  610. LONG_PTR Result = -1;
  611. //
  612. // The MapPrinter will allocate memory, set default devmode, reading and
  613. // validating the GPC then update from current pritner registry, it also
  614. // will cached the pPI.
  615. if ((!pPSUIInfo) ||
  616. (!(pDPHdr = (PDEVICEPROPERTYHEADER)pPSUIInfo->lParamInit))) {
  617. SetLastError(ERROR_INVALID_DATA);
  618. return(ERR_CPSUI_GETLASTERROR);
  619. }
  620. if (pPSUIInfo->Reason == PROPSHEETUI_REASON_INIT) {
  621. if (!(pPI = MapPrinter(pDPHdr->hPrinter,
  622. NULL,
  623. NULL,
  624. MPF_HELPFILE | MPF_DEVICEDATA | MPF_PCPSUI))) {
  625. PLOTRIP(("DrvDevicePropertySheets: MapPrinter() failed"));
  626. SetLastError(ERROR_INVALID_DATA);
  627. return(ERR_CPSUI_GETLASTERROR);
  628. }
  629. pPI->Flags = (pDPHdr->Flags & DPS_NOPERMISSION) ?
  630. 0 : PIF_UPDATE_PERMISSION;
  631. pPI->pCPSUI->Flags = 0;
  632. pPI->pCPSUI->pfnCallBack = PPCallBack;
  633. pPI->pCPSUI->pDlgPage = CPSUI_PDLGPAGE_PRINTERPROP;
  634. //
  635. // Add form to the database and find out if we can update
  636. //
  637. // Move to DrvPrinterEven()
  638. //
  639. //
  640. // AddFormsToDataBase(pPI, TRUE);
  641. //
  642. Result = (LONG_PTR)SetupPPOptItems(pPI);
  643. } else {
  644. pPI = (PPRINTERINFO)pPSUIInfo->UserData;
  645. Result = (LONG_PTR)pDPHdr->pszPrinterName;
  646. }
  647. return(DefCommonUIFunc(pPSUIInfo, lParam, pPI, Result));
  648. }
  649. BOOL
  650. PrinterProperties(
  651. HWND hWnd,
  652. HANDLE hPrinter
  653. )
  654. /*++
  655. Routine Description:
  656. This function first retrieves and displays the current set of printer
  657. properties for the printer. The user is allowed to change the current
  658. printer properties from the displayed dialog box.
  659. Arguments:
  660. hWnd - Handle to the caller's window (parent window)
  661. hPrinter - Handle to the pritner interested
  662. Return Value:
  663. TRUE if function sucessful FALSE if failed
  664. Author:
  665. 06-Dec-1993 Mon 11:21:28 created
  666. Revision History:
  667. --*/
  668. {
  669. PRINTER_INFO_4 *pPI4;
  670. DEVICEPROPERTYHEADER DPHdr;
  671. LONG Result = CPSUI_CANCEL;
  672. pPI4 = (PRINTER_INFO_4 *)GetPrinterInfo(hPrinter, 4);
  673. DPHdr.cbSize = sizeof(DPHdr);
  674. DPHdr.Flags = 0;
  675. DPHdr.hPrinter = hPrinter;
  676. DPHdr.pszPrinterName = (pPI4) ? pPI4->pPrinterName : NULL;
  677. CallCommonPropertySheetUI(hWnd,
  678. DrvDevicePropertySheets,
  679. (LPARAM)&DPHdr,
  680. (LPDWORD)&Result);
  681. if (pPI4) {
  682. LocalFree((HLOCAL)pPI4);
  683. }
  684. return(Result == CPSUI_OK);
  685. }
  686. BOOL
  687. DrvPrinterEvent(
  688. LPWSTR pPrinterName,
  689. INT Event,
  690. DWORD Flags,
  691. LPARAM lParam
  692. )
  693. /*++
  694. Routine Description:
  695. Arguments:
  696. Return Value:
  697. Author:
  698. 08-May-1996 Wed 17:38:34 created
  699. Revision History:
  700. 04-Jun-1996 Tue 14:51:25 updated
  701. Matched a ClosePrinter() to OpenPrinter()
  702. --*/
  703. {
  704. PRINTER_DEFAULTS PrinterDef = { NULL, NULL, PRINTER_ALL_ACCESS };
  705. HANDLE hPrinter;
  706. BOOL bRet = TRUE;
  707. switch (Event) {
  708. case PRINTER_EVENT_INITIALIZE:
  709. if (OpenPrinter(pPrinterName, &hPrinter, &PrinterDef)) {
  710. PPRINTERINFO pPI;
  711. if (pPI = MapPrinter(hPrinter, NULL, NULL, MPF_DEVICEDATA)) {
  712. bRet = AddFormsToDataBase(pPI, FALSE);
  713. UnMapPrinter(pPI);
  714. }
  715. ClosePrinter(hPrinter);
  716. }
  717. break;
  718. default:
  719. break;
  720. }
  721. return(bRet);
  722. }