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.

1116 lines
27 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. docprop.c
  5. Abstract:
  6. This module contains functions for DrvDocumentPropertySheets
  7. Author:
  8. 07-Dec-1993 Tue 12:15:40 created
  9. [Environment:]
  10. GDI Device Driver - Plotter.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #define DBG_PLOTFILENAME DbgDocProp
  17. extern HMODULE hPlotUIModule;
  18. #define DBG_DP_SETUP 0x00000001
  19. #define DBG_DP_FORM 0x00000002
  20. #define DBG_HELP 0x00000004
  21. DEFINE_DBGVAR(0);
  22. OPDATA OPOrientation[] = {
  23. { 0, IDS_CPSUI_PORTRAIT, IDI_CPSUI_PORTRAIT, 0, 0, 0 },
  24. { 0, IDS_CPSUI_LANDSCAPE, IDI_CPSUI_LANDSCAPE, 0, 0, 0 }
  25. };
  26. OPDATA OPColor[] = {
  27. { 0, IDS_CPSUI_MONOCHROME, IDI_CPSUI_MONO, 0, 0, 0 },
  28. { 0, IDS_CPSUI_COLOR, IDI_CPSUI_COLOR, 0, 0, 0 }
  29. };
  30. OPDATA OPCopyCollate[] = {
  31. { 0, IDS_CPSUI_COPIES, IDI_CPSUI_COPY, 0, 0, 0 },
  32. { 0, 0, 1, 0, 0, 100 }
  33. };
  34. OPDATA OPScaling[] = {
  35. { 0, IDS_CPSUI_PERCENT, IDI_CPSUI_SCALING, 0, 0, 0 },
  36. { 0, 0, 1, 0, 0, 100 }
  37. };
  38. OPDATA OPPrintQuality[] = {
  39. { 0, IDS_QUALITY_DRAFT, IDI_CPSUI_RES_DRAFT, 0, 0, -1 },
  40. { 0, IDS_QUALITY_LOW, IDI_CPSUI_RES_LOW, 0, 0, -2 },
  41. { 0, IDS_QUALITY_MEDIUM, IDI_CPSUI_RES_MEDIUM, 0, 0, -3 },
  42. { 0, IDS_QUALITY_HIGH, IDI_CPSUI_RES_PRESENTATION, 0, 0, -4 }
  43. };
  44. OPDATA OPHTClrAdj = {
  45. 0,
  46. PI_OFF(PlotDM) + PLOTDM_OFF(ca),
  47. IDI_CPSUI_HTCLRADJ,
  48. PUSHBUTTON_TYPE_HTCLRADJ,
  49. 0,
  50. 0
  51. };
  52. extern OPDATA OPNoYes[];
  53. OPDATA OPFillTrueType[] = {
  54. { 0, IDS_CPSUI_NO, IDI_FILL_TRUETYPE_NO, 0, 0, 0 },
  55. { 0, IDS_CPSUI_YES, IDI_FILL_TRUETYPE_YES, 0, 0, 0 }
  56. };
  57. OIDATA DPOIData[] = {
  58. {
  59. ODF_PEN_RASTER | ODF_CALLCREATEOI,
  60. 0,
  61. OI_LEVEL_1,
  62. DMPUB_FORMNAME,
  63. TVOT_LISTBOX,
  64. IDS_CPSUI_FORMNAME,
  65. 0,
  66. IDH_FORMNAME,
  67. 0,
  68. (POPDATA)CreateFormOI
  69. },
  70. {
  71. ODF_PEN_RASTER,
  72. 0,
  73. OI_LEVEL_1,
  74. DMPUB_ORIENTATION,
  75. TVOT_2STATES,
  76. IDS_CPSUI_ORIENTATION,
  77. 0,
  78. IDH_ORIENTATION,
  79. COUNT_ARRAY(OPOrientation),
  80. OPOrientation
  81. },
  82. {
  83. ODF_PEN_RASTER,
  84. 0,
  85. OI_LEVEL_1,
  86. DMPUB_COPIES_COLLATE,
  87. TVOT_UDARROW,
  88. IDS_CPSUI_NUM_OF_COPIES,
  89. 0,
  90. IDH_COPIES_COLLATE,
  91. COUNT_ARRAY(OPCopyCollate),
  92. OPCopyCollate
  93. },
  94. {
  95. ODF_PEN_RASTER,
  96. 0,
  97. OI_LEVEL_1,
  98. DMPUB_PRINTQUALITY,
  99. TVOT_LISTBOX,
  100. IDS_CPSUI_PRINTQUALITY,
  101. 0,
  102. IDH_PRINTQUALITY,
  103. COUNT_ARRAY(OPPrintQuality),
  104. OPPrintQuality
  105. },
  106. {
  107. ODF_RASTER | ODF_COLOR,
  108. 0,
  109. OI_LEVEL_1,
  110. DMPUB_COLOR,
  111. TVOT_2STATES,
  112. IDS_CPSUI_COLOR_APPERANCE,
  113. 0,
  114. IDH_COLOR,
  115. COUNT_ARRAY(OPColor),
  116. OPColor
  117. },
  118. {
  119. ODF_PEN_RASTER,
  120. 0,
  121. OI_LEVEL_1,
  122. DMPUB_SCALE,
  123. TVOT_UDARROW,
  124. IDS_CPSUI_SCALING,
  125. 0,
  126. IDH_SCALE,
  127. COUNT_ARRAY(OPScaling),
  128. OPScaling
  129. },
  130. {
  131. ODF_RASTER,
  132. 0,
  133. OI_LEVEL_1,
  134. DP_HTCLRADJ,
  135. TVOT_PUSHBUTTON,
  136. IDS_CPSUI_HTCLRADJ,
  137. OTS_PUSH_ENABLE_ALWAYS,
  138. IDH_HTCLRADJ,
  139. 1,
  140. &OPHTClrAdj
  141. },
  142. {
  143. ODF_PEN,
  144. 0,
  145. OI_LEVEL_1,
  146. DP_FILL_TRUETYPE,
  147. TVOT_2STATES,
  148. IDS_FILL_TRUETYPE,
  149. 0,
  150. IDH_FILL_TRUETYPE,
  151. 2,
  152. OPFillTrueType
  153. },
  154. {
  155. ODF_RASTER,
  156. 0,
  157. OI_LEVEL_1,
  158. DP_QUICK_POSTER_MODE,
  159. TVOT_2STATES,
  160. IDS_POSTER_MODE,
  161. 0,
  162. IDH_POSTER_MODE,
  163. 2,
  164. OPNoYes
  165. }
  166. };
  167. UINT
  168. SetupDPOptItems(
  169. PPRINTERINFO pPI
  170. )
  171. /*++
  172. Routine Description:
  173. Arguments:
  174. Return Value:
  175. Author:
  176. 16-Nov-1995 Thu 14:15:25 created
  177. Revision History:
  178. --*/
  179. {
  180. PPLOTDEVMODE pPlotDM;
  181. PPLOTGPC pPlotGPC;
  182. POPTITEM pOptItem;
  183. POPTITEM pOI;
  184. POIDATA pOIData;
  185. DWORD Flags;
  186. DWORD ODFlags;
  187. UINT i;
  188. pOI =
  189. pOptItem = pPI->pOptItem;
  190. pOIData = DPOIData;
  191. i = (UINT)COUNT_ARRAY(DPOIData);
  192. pPlotGPC = pPI->pPlotGPC;
  193. pPlotDM = &(pPI->PlotDM);
  194. Flags = pPlotGPC->Flags;
  195. ODFlags = (Flags & PLOTF_RASTER) ? ODF_RASTER : ODF_PEN;
  196. while (i--) {
  197. DWORD OIFlags = pOIData->Flags;
  198. switch (pOIData->DMPubID) {
  199. case DMPUB_COPIES_COLLATE:
  200. if (pPlotGPC->MaxCopies <= 1) {
  201. OIFlags = 0;
  202. }
  203. break;
  204. case DMPUB_SCALE:
  205. if (!pPlotGPC->MaxScale) {
  206. OIFlags = 0;
  207. }
  208. break;
  209. }
  210. if ((!(OIFlags & ODFlags)) ||
  211. ((OIFlags & ODF_ROLLFEED) && (!(Flags & PLOTF_ROLLFEED))) ||
  212. ((OIFlags & ODF_NO_PAPERTRAY) && (Flags & PLOTF_PAPERTRAY)) ||
  213. ((OIFlags & ODF_COLOR) && (!(Flags & PLOTF_COLOR)))) {
  214. //
  215. // Nothing to do here
  216. //
  217. NULL;
  218. } else if (OIFlags & ODF_CALLCREATEOI) {
  219. pOI += pOIData->pfnCreateOI(pPI,
  220. (LPVOID)((pOptItem) ? pOI : NULL),
  221. pOIData);
  222. } else if (pOptItem) {
  223. if (CreateOPTTYPE(pPI, pOI, pOIData, pOIData->cOPData, NULL)) {
  224. POPTPARAM pOP = pOI->pOptType->pOptParam;
  225. switch (pOI->DMPubID) {
  226. case DMPUB_ORIENTATION:
  227. pOI->Sel = (LONG)((pPlotDM->dm.dmOrientation ==
  228. DMORIENT_PORTRAIT) ? 0 : 1);
  229. break;
  230. case DMPUB_COPIES_COLLATE:
  231. pOP[1].lParam = (LONG)pPlotGPC->MaxCopies;
  232. pOI->Sel = (LONG)pPlotDM->dm.dmCopies;
  233. break;
  234. case DMPUB_PRINTQUALITY:
  235. switch (pPlotGPC->MaxQuality) {
  236. case 0:
  237. case 1:
  238. pPlotDM->dm.dmPrintQuality = DMRES_HIGH;
  239. pOP[0].Flags |= OPTPF_HIDE;
  240. case 2:
  241. pOP[2].Flags |= OPTPF_HIDE;
  242. case 3:
  243. pOP[1].Flags |= OPTPF_HIDE;
  244. break;
  245. default:
  246. break;
  247. }
  248. pOI->Sel = (LONG)-(pPlotDM->dm.dmPrintQuality -
  249. DMRES_DRAFT);
  250. break;
  251. case DMPUB_COLOR:
  252. pOI->Sel = (LONG)((pPlotDM->dm.dmColor == DMCOLOR_COLOR) ?
  253. 1 : 0);
  254. break;
  255. case DMPUB_SCALE:
  256. pOP[1].lParam = (LONG)pPlotGPC->MaxScale;
  257. pOI->Sel = (LONG)pPlotDM->dm.dmScale;
  258. break;
  259. case DP_FILL_TRUETYPE:
  260. pOI->Sel = (LONG)((pPlotDM->Flags & PDMF_FILL_TRUETYPE) ?
  261. 1 : 0);
  262. break;
  263. case DP_QUICK_POSTER_MODE:
  264. pOI->Sel = (LONG)((pPlotDM->Flags & PDMF_PLOT_ON_THE_FLY) ?
  265. 1 : 0);
  266. break;
  267. }
  268. pOI++;
  269. }
  270. } else {
  271. pOI++;
  272. }
  273. pOIData++;
  274. }
  275. if ((i = (UINT)(pOI - pOptItem)) && (!pOptItem)) {
  276. if (pPI->pOptItem = (POPTITEM)LocalAlloc(LPTR, sizeof(OPTITEM) * i)) {
  277. pPI->cOptItem = (WORD)i;
  278. //
  279. // Call myself second time to really create it
  280. //
  281. SetupDPOptItems(pPI);
  282. } else {
  283. i = 0;
  284. PLOTERR(("GetPPpOptItem(): LocalAlloc(%ld) failed",
  285. sizeof(OPTITEM) * i));
  286. }
  287. }
  288. return(i);
  289. }
  290. VOID
  291. SaveDPOptItems(
  292. PPRINTERINFO pPI
  293. )
  294. /*++
  295. Routine Description:
  296. This function save all the device options back to registry if one changed
  297. and has a update permission
  298. Arguments:
  299. pPI - Pointer to the PRINTERINFO
  300. Return Value:
  301. VOID
  302. Author:
  303. 06-Nov-1995 Mon 18:05:16 created
  304. Revision History:
  305. --*/
  306. {
  307. POPTITEM pOI;
  308. POPTITEM pLastItem;
  309. PPLOTDEVMODE pPlotDM;
  310. BYTE DMPubID;
  311. pOI = pPI->pOptItem;
  312. pLastItem = pOI + pPI->cOptItem - 1;
  313. pPlotDM = &(pPI->PlotDM);
  314. while (pOI <= pLastItem) {
  315. if (pOI->Flags & OPTIF_CHANGEONCE) {
  316. switch (pOI->DMPubID) {
  317. case DMPUB_FORMNAME:
  318. GetFormSelect(pPI, pOI);
  319. break;
  320. case DMPUB_ORIENTATION:
  321. pPlotDM->dm.dmOrientation = (SHORT)((pOI->Sel) ?
  322. DMORIENT_LANDSCAPE :
  323. DMORIENT_PORTRAIT);
  324. break;
  325. case DMPUB_COPIES_COLLATE:
  326. pPlotDM->dm.dmCopies = (SHORT)pOI->Sel;
  327. break;
  328. case DMPUB_PRINTQUALITY:
  329. pPlotDM->dm.dmPrintQuality = (SHORT)(-(pOI->Sel) + DMRES_DRAFT);
  330. break;
  331. case DMPUB_COLOR:
  332. pPlotDM->dm.dmColor = (SHORT)((pOI->Sel) ? DMCOLOR_COLOR :
  333. DMCOLOR_MONOCHROME);
  334. break;
  335. case DMPUB_SCALE:
  336. pPlotDM->dm.dmScale = (SHORT)pOI->Sel;
  337. break;
  338. case DP_FILL_TRUETYPE:
  339. if (pOI->Sel) {
  340. pPlotDM->Flags |= PDMF_FILL_TRUETYPE;
  341. } else {
  342. pPlotDM->Flags &= ~PDMF_FILL_TRUETYPE;
  343. }
  344. break;
  345. case DP_QUICK_POSTER_MODE:
  346. if (pOI->Sel) {
  347. pPlotDM->Flags |= PDMF_PLOT_ON_THE_FLY;
  348. } else {
  349. pPlotDM->Flags &= ~PDMF_PLOT_ON_THE_FLY;
  350. }
  351. break;
  352. }
  353. }
  354. pOI++;
  355. }
  356. }
  357. CPSUICALLBACK
  358. DPCallBack(
  359. PCPSUICBPARAM pCPSUICBParam
  360. )
  361. /*++
  362. Routine Description:
  363. This is the callback function from the common property sheet UI
  364. Arguments:
  365. pCPSUICBParam - Pointer to the CPSUICBPARAM data structure to describe
  366. the nature of the callback
  367. Return Value:
  368. LONG
  369. Author:
  370. 07-Nov-1995 Tue 15:15:02 created
  371. Revision History:
  372. --*/
  373. {
  374. POPTITEM pCurItem = pCPSUICBParam->pCurItem;
  375. LONG Action = CPSUICB_ACTION_NONE;
  376. if (pCPSUICBParam->Reason == CPSUICB_REASON_APPLYNOW) {
  377. PPRINTERINFO pPI = (PPRINTERINFO)pCPSUICBParam->UserData;
  378. if ((pPI->Flags & PIF_UPDATE_PERMISSION) &&
  379. (pPI->pPlotDMOut)) {
  380. SaveDPOptItems(pPI);
  381. PLOTDBG(DBG_DP_SETUP, ("APPLYNOW: ConvertDevmodeOut"));
  382. ConvertDevmodeOut((PDEVMODE)&(pPI->PlotDM),
  383. (PDEVMODE)pPI->pPlotDMIn,
  384. (PDEVMODE)pPI->pPlotDMOut);
  385. pCPSUICBParam->Result = CPSUI_OK;
  386. Action = CPSUICB_ACTION_ITEMS_APPLIED;
  387. }
  388. }
  389. return(Action);
  390. }
  391. BOOL
  392. DrvConvertDevMode(
  393. LPTSTR pPrinterName,
  394. PDEVMODE pDMIn,
  395. PDEVMODE pDMOut,
  396. PLONG pcbNeeded,
  397. DWORD fMode
  398. )
  399. /*++
  400. Routine Description:
  401. This function is used by the SetPrinter() and GetPrinter() spooler calls.
  402. Arguments:
  403. pPrinterName - Points to printer name string
  404. pDMIn - Points to the input devmode
  405. pDMOut - Points to the output devmode buffer
  406. pcbNeeded - Specifies the size of output buffer on input On output,
  407. this is the size of output devmode
  408. fMode - Specifies what function to perform
  409. Return Value:
  410. TRUE if successful
  411. FALSE otherwise and an error code is logged
  412. Author:
  413. 08-Jan-1996 Mon 12:40:22 created
  414. Revision History:
  415. --*/
  416. {
  417. DWORD cb;
  418. INT Result;
  419. static DRIVER_VERSION_INFO PlotDMVersions = {
  420. DRIVER_VERSION, PLOTDM_PRIV_SIZE, // current version/size
  421. 0x0350, PLOTDM_PRIV_SIZE, // NT3.51 version/size
  422. };
  423. //
  424. // Call a library routine to handle the common cases
  425. //
  426. Result = CommonDrvConvertDevmode(pPrinterName,
  427. pDMIn,
  428. pDMOut,
  429. pcbNeeded,
  430. fMode,
  431. &PlotDMVersions);
  432. //
  433. // If not handled by the library routine, we only need to worry
  434. // about the case when fMode is CDM_DRIVER_DEFAULT
  435. //
  436. if ((Result == CDM_RESULT_NOT_HANDLED) &&
  437. (fMode == CDM_DRIVER_DEFAULT)) {
  438. HANDLE hPrinter;
  439. if (OpenPrinter(pPrinterName, &hPrinter, NULL)) {
  440. PPLOTGPC pPlotGPC;
  441. if (pPlotGPC = hPrinterToPlotGPC(hPrinter, pDMOut->dmDeviceName, CCHOF(pDMOut->dmDeviceName))) {
  442. SetDefaultPLOTDM(hPrinter,
  443. pPlotGPC,
  444. pDMOut->dmDeviceName,
  445. (PPLOTDEVMODE)pDMOut,
  446. NULL);
  447. UnGetCachedPlotGPC(pPlotGPC);
  448. Result = CDM_RESULT_TRUE;
  449. } else {
  450. PLOTERR(("DrvConvertDevMode: hPrinterToPlotGPC(%ws) failed.",
  451. pPrinterName));
  452. SetLastError(ERROR_INVALID_DATA);
  453. }
  454. ClosePrinter(hPrinter);
  455. } else {
  456. PLOTERR(("DrvConvertDevMode: OpenPrinter(%ws) failed.",
  457. pPrinterName));
  458. SetLastError(ERROR_INVALID_DATA);
  459. }
  460. }
  461. return(Result == CDM_RESULT_TRUE);
  462. }
  463. LONG
  464. DrvDocumentPropertySheets(
  465. PPROPSHEETUI_INFO pPSUIInfo,
  466. LPARAM lParam
  467. )
  468. /*++
  469. Routine Description:
  470. Show document property dialog box and update the output DEVMODE
  471. Arguments:
  472. pPSUIInfo - Pointer to the PROPSHEETUI_INFO data structure
  473. lParam - LPARAM for this call, it is a pointer to the
  474. DOCUMENTPROPERTYHEADER
  475. Return Value:
  476. LONG, 1=successful, 0=failed.
  477. Author:
  478. 02-Feb-1996 Fri 10:47:42 created
  479. Revision History:
  480. --*/
  481. {
  482. PDOCUMENTPROPERTYHEADER pDPHdr;
  483. PPRINTERINFO pPI;
  484. LONG_PTR Result;
  485. //
  486. // Assume faild first
  487. //
  488. Result = -1;
  489. if (pPSUIInfo) {
  490. if (!(pDPHdr = (PDOCUMENTPROPERTYHEADER)pPSUIInfo->lParamInit)) {
  491. PLOTERR(("DrvDocumentPropertySheets: Pass a NULL lParamInit"));
  492. return(-1);
  493. }
  494. } else {
  495. if (pDPHdr = (PDOCUMENTPROPERTYHEADER)lParam) {
  496. //
  497. // We do not have pPSUIInfo, so that we assume this is call
  498. // directly from the spooler and lParam is the pDPHdr
  499. //
  500. if ((pDPHdr->fMode == 0) || (pDPHdr->pdmOut == NULL)) {
  501. Result = (pDPHdr->cbOut = sizeof(PLOTDEVMODE));
  502. } else if ((pDPHdr->fMode & (DM_COPY | DM_UPDATE)) &&
  503. (!(pDPHdr->fMode & DM_NOPERMISSION)) &&
  504. (pDPHdr->pdmOut)) {
  505. //
  506. // The MapPrinter will allocate memory, set default devmode,
  507. // reading and validating the GPC then update from current pritner
  508. // registry, it also will cached the pPI.
  509. //
  510. if (pPI = MapPrinter(pDPHdr->hPrinter,
  511. (PPLOTDEVMODE)pDPHdr->pdmIn,
  512. NULL,
  513. 0)) {
  514. ConvertDevmodeOut((PDEVMODE)&(pPI->PlotDM),
  515. (PDEVMODE)pDPHdr->pdmIn,
  516. (PDEVMODE)pDPHdr->pdmOut);
  517. Result = 1;
  518. UnMapPrinter(pPI);
  519. } else {
  520. PLOTRIP(("DrvDocumentPropertySheets: MapPrinter() failed"));
  521. }
  522. } else {
  523. Result = 1;
  524. }
  525. } else {
  526. PLOTRIP(("DrvDocumentPropertySheets: ??? pDPHdr (lParam) = NULL"));
  527. }
  528. return((LONG)Result);
  529. }
  530. //
  531. // Now, this is the call from common UI, assume error to start with
  532. //
  533. if (pPSUIInfo->Reason == PROPSHEETUI_REASON_INIT) {
  534. if (!(pPI = MapPrinter(pDPHdr->hPrinter,
  535. (PPLOTDEVMODE)pDPHdr->pdmIn,
  536. NULL,
  537. MPF_HELPFILE | MPF_PCPSUI))) {
  538. PLOTRIP(("DrvDocumentPropertySheets: MapPrinter() failed"));
  539. SetLastError(ERROR_INVALID_DATA);
  540. return(ERR_CPSUI_GETLASTERROR);
  541. }
  542. if ((pDPHdr->fMode & (DM_COPY | DM_UPDATE)) &&
  543. (!(pDPHdr->fMode & DM_NOPERMISSION)) &&
  544. (pDPHdr->pdmOut)) {
  545. pPI->Flags = (PIF_DOCPROP | PIF_UPDATE_PERMISSION);
  546. pPI->pPlotDMOut = (PPLOTDEVMODE)pDPHdr->pdmOut;
  547. } else {
  548. pPI->Flags = PIF_DOCPROP;
  549. pPI->pPlotDMOut = NULL;
  550. }
  551. //
  552. // We need to display something to let user modify/update, we wll check
  553. // which document properties dialog box to be used
  554. //
  555. // The return value either IDOK or IDCANCEL
  556. //
  557. pPI->pCPSUI->Flags = 0;
  558. pPI->pCPSUI->pfnCallBack = DPCallBack;
  559. pPI->pCPSUI->pDlgPage = (pDPHdr->fMode & DM_ADVANCED) ?
  560. CPSUI_PDLGPAGE_ADVDOCPROP :
  561. CPSUI_PDLGPAGE_DOCPROP;
  562. Result = (LONG_PTR)SetupDPOptItems(pPI);
  563. } else {
  564. pPI = (PPRINTERINFO)pPSUIInfo->UserData;
  565. Result = (LONG_PTR)pDPHdr->pszPrinterName;
  566. }
  567. return(DefCommonUIFunc(pPSUIInfo, lParam, pPI, Result));
  568. }
  569. // @@BEGIN_DDKSPLIT
  570. // DrvDocumentProperties() and DrvAdvancedDocumentProperties()
  571. // are obsolete, but we keep them here for old application which
  572. // might be using these. But, we don't want these in the DDK samples.
  573. LONG
  574. DrvDocumentProperties(
  575. HWND hWnd,
  576. HANDLE hPrinter,
  577. LPWSTR pwDeviceName,
  578. PPLOTDEVMODE pDMOut,
  579. PPLOTDEVMODE pDMIn,
  580. DWORD fMode
  581. )
  582. /*++
  583. Routine Description:
  584. DrvDocumentProperties sets the public members of a PLOTDEVMODE structure
  585. for the given print document.
  586. Arguments:
  587. hWnd - Identifies the parent window of the printer-configuration
  588. dialog box.
  589. hPrinter - Identifies a printer object.
  590. pwDeviceName - Points to a zero-terminated string that specifies the
  591. name of the device for which the printer-configuration
  592. dialog box should be displayed.
  593. pDMOut - Points to a PLOTDEVMODE structure that initializes the
  594. dialog box controls. NULL forces the use of the default
  595. values.
  596. pDMIn - Points to a PLOTDEVMODE structure that receives the
  597. printer configuration data specified by the user.
  598. fMode - Specifies a mask of values that determines which
  599. operations the function performs. If this parameter is
  600. zero, DrvDocumentProperties returns the number of bytes
  601. required by the printer driver's PLOTDEVMODE structure.
  602. Otherwise, use one or more of the following constants to
  603. construct a value for this parameter; note, however, that
  604. in order to change the print settings, an application
  605. must specify at least one input value and one output
  606. value:
  607. Value Meaning
  608. ------------------------------------------------------------------
  609. DM_IN_BUFFER Input value. Before prompting, copying, or updating,
  610. (DM_MODIFY) the function merges the printer driver's current
  611. print settings with the settings in the PLOTDEVMODE
  612. specified by the pDMIn parameter. The structure
  613. is updated only for those members specified by the
  614. PLOTDEVMODE structure's dmFields member. This
  615. value is also defined as DM_MODIFY.
  616. DM_IN_PROMPT Input value. The function presents the print
  617. (DM_PROMPT) driver's Print Setup dialog box, then change the
  618. settings in the printer's PLOTDEVMODE structure to
  619. the values specified by the user. This value is
  620. also defined as DM_PROMPT.
  621. DM_OUT_BUFFER Output value. The function writes the printer
  622. (DM_COPY) driver's current print settings, including private
  623. data, to the PLOTDEVMODE structure specified by
  624. pDMOut. The caller must allocate a buffer large
  625. enough to contain the information. If the bit
  626. DM_OUT_BUFFER is clear, pDMOut can be NULL. This
  627. value is also defined as DM_COPY.
  628. Return Value:
  629. If fMode is zero, the return value is the size of the buffer (in bytes)
  630. required to contain the printer driver initialization data. Note that this
  631. buffer will generally be larger than the PLOTDEVMODE structure if the
  632. printer driver appends private data to the structure. If the function
  633. displays the initialization dialog box, the return value is either IDOK or
  634. IDCANCEL, depending on which button the user selects.
  635. If the function does not display the dialog box and is successful, the
  636. return value is IDOK. If the function fails, the return value is less than
  637. zero.
  638. In order to change print settings that are local to an application, the
  639. application should:
  640. * Call with fMode = 0 to get the size of DM_OUT_BUFFER.
  641. * Modify the returned PLOTDEVMODE structure.
  642. * Pass the modified PLOTDEVMODE back by calling DrvDocumentProperties,
  643. specifying both DM_IN_BUFFER and DM_OUT_BUFFER.
  644. Author:
  645. 15-Dec-1993 Wed 15:07:01 updated
  646. it seems that spooler never passed a DM_MODIFY to the driver, and that
  647. caused we never merge the input devmode, we will assume that user has
  648. valid DM_IN_BUFFER/DM_MODIFY bit set if the pDMIn is not a NULL
  649. pointer.
  650. 07-Dec-1993 Tue 12:19:47 created
  651. Revision History:
  652. --*/
  653. {
  654. DOCUMENTPROPERTYHEADER DPHdr;
  655. LONG Result;
  656. DPHdr.cbSize = sizeof(DPHdr);
  657. DPHdr.Reserved = 0;
  658. DPHdr.hPrinter = hPrinter;
  659. DPHdr.pszPrinterName = pwDeviceName;
  660. DPHdr.pdmIn = (PDEVMODE)pDMIn;
  661. DPHdr.pdmOut = (PDEVMODE)pDMOut;
  662. DPHdr.cbOut = sizeof(PLOTDEVMODE);
  663. DPHdr.fMode = fMode;
  664. PLOTDBG(DBG_DP_SETUP, ("DocProp: fMode=%08lx, %ws%ws%ws%ws",
  665. fMode,
  666. (INT_PTR)((fMode & DM_UPDATE) ? L"DM_UPDATE " : L""),
  667. (INT_PTR)((fMode & DM_COPY ) ? L"DM_COPY " : L""),
  668. (INT_PTR)((fMode & DM_PROMPT) ? L"DM_PROMPT " : L""),
  669. (INT_PTR)((fMode & DM_MODIFY) ? L"DM_MODIFY " : L"")));
  670. if (fMode & DM_PROMPT) {
  671. Result = CPSUI_CANCEL;
  672. if (CallCommonPropertySheetUI(hWnd,
  673. DrvDocumentPropertySheets,
  674. (LPARAM)&DPHdr,
  675. (LPDWORD)&Result) < 0) {
  676. Result = CPSUI_CANCEL;
  677. }
  678. PLOTDBG(DBG_DP_SETUP, ("Result=%hs",
  679. (Result == CPSUI_OK) ? "IDOK" : "IDCANCEL"));
  680. return((Result == CPSUI_OK) ? IDOK : IDCANCEL);
  681. } else {
  682. return(DrvDocumentPropertySheets(NULL, (LPARAM)&DPHdr));
  683. }
  684. }
  685. LONG
  686. DrvAdvancedDocumentProperties(
  687. HWND hWnd,
  688. HANDLE hPrinter,
  689. LPWSTR pwDeviceName,
  690. PPLOTDEVMODE pDMOut,
  691. PPLOTDEVMODE pDMIn
  692. )
  693. /*++
  694. Routine Description:
  695. DrvAdvancedDocumentProperties sets the public members of a PLOTDEVMODE
  696. structure for the given print document.
  697. Arguments:
  698. hWnd - Identifies the parent window of the printer-configuration
  699. dialog box.
  700. hPrinter - Identifies a printer object.
  701. pwDeviceName - Points to a zero-terminated string that specifies the
  702. name of the device for which the printer-configuration
  703. dialog box should be displayed.
  704. pDMOut - Points to a PLOTDEVMODE structure that initializes the
  705. dialog box controls. NULL forces the use of the default
  706. values.
  707. pDMIn - Points to a PLOTDEVMODE structure that receives the
  708. printer configuration data specified by the user.
  709. Return Value:
  710. LONG value depends on the dilaog box outcome eiterh IDOK or IDCANCEL, if
  711. an error occurred then a negative number is returned
  712. Author:
  713. 07-Dec-1993 Tue 12:19:47 created
  714. Revision History:
  715. --*/
  716. {
  717. return((DrvDocumentProperties(hWnd,
  718. hPrinter,
  719. pwDeviceName,
  720. pDMOut,
  721. pDMIn,
  722. DM_PROMPT |
  723. DM_MODIFY |
  724. DM_COPY |
  725. DM_ADVANCED) == CPSUI_OK) ? 1 : 0);
  726. }
  727. // @@END_DDKSPLIT