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.

594 lines
16 KiB

  1. /*++
  2. Copyright (c) 1990-2001 Microsoft Corporation
  3. Module Name:
  4. WinDDIUI.h
  5. Abstract:
  6. Header file for the UI portion of printer drivers.
  7. Revision History:
  8. --*/
  9. #ifndef _WINDDIUI_
  10. #define _WINDDIUI_
  11. #include <compstui.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. //
  16. // DrvDevicePropertySheets replace previous version of PrinterProperties
  17. //
  18. LONG WINAPI
  19. DrvDevicePropertySheets(
  20. PPROPSHEETUI_INFO pPSUIInfo,
  21. LPARAM lParam
  22. );
  23. typedef struct _DEVICEPROPERTYHEADER {
  24. WORD cbSize;
  25. WORD Flags;
  26. HANDLE hPrinter;
  27. LPTSTR pszPrinterName;
  28. } DEVICEPROPERTYHEADER, *PDEVICEPROPERTYHEADER;
  29. #define DPS_NOPERMISSION 0x0001
  30. //
  31. // For document properties replace DocumentProperties.
  32. //
  33. // Note: if pPSUIInfo is NULL then the call need not to display any dialog
  34. // boxes (Ignored the DC_PROMPT bit in the fMode, the lParam in this case
  35. // is a pointer to DOCUMENTPROPERTYHEADER
  36. //
  37. LONG WINAPI
  38. DrvDocumentPropertySheets(
  39. PPROPSHEETUI_INFO pPSUIInfo,
  40. LPARAM lParam
  41. );
  42. typedef struct _DOCUMENTPROPERTYHEADER {
  43. WORD cbSize;
  44. WORD Reserved;
  45. HANDLE hPrinter;
  46. LPTSTR pszPrinterName;
  47. PDEVMODE pdmIn;
  48. PDEVMODE pdmOut;
  49. DWORD cbOut;
  50. DWORD fMode;
  51. } DOCUMENTPROPERTYHEADER, *PDOCUMENTPROPERTYHEADER;
  52. #define DM_ADVANCED 0x10
  53. #define DM_NOPERMISSION 0x20
  54. #define DM_USER_DEFAULT 0x40
  55. // Devmode conversion function used by GetPrinter and SetPrinter
  56. BOOL WINAPI
  57. DrvConvertDevMode(
  58. LPTSTR pPrinterName,
  59. PDEVMODE pdmIn,
  60. PDEVMODE pdmOut,
  61. PLONG pcbNeeded,
  62. DWORD fMode
  63. );
  64. #define CDM_CONVERT 0x01
  65. #define CDM_CONVERT351 0x02
  66. #define CDM_DRIVER_DEFAULT 0x04
  67. //
  68. // This is for DevQueryPrintEx()
  69. //
  70. typedef struct _DEVQUERYPRINT_INFO {
  71. WORD cbSize; // size of this structure in bytes
  72. WORD Level; // Level of this info, 1 for this version
  73. HANDLE hPrinter; // handle to the printer for the query
  74. DEVMODE *pDevMode; // pointer to the DEVMODE for this job.
  75. LPTSTR pszErrorStr; // pointer to the error string buffer.
  76. DWORD cchErrorStr; // count characters of pwErrorStr passed.
  77. DWORD cchNeeded; // count characters of pwErrorStr needed.
  78. } DEVQUERYPRINT_INFO, *PDEVQUERYPRINT_INFO;
  79. BOOL WINAPI
  80. DevQueryPrintEx(
  81. PDEVQUERYPRINT_INFO pDQPInfo
  82. );
  83. //
  84. // This for the DrvUpgradePrinter
  85. //
  86. typedef struct _DRIVER_UPGRADE_INFO_1 {
  87. LPTSTR pPrinterName;
  88. LPTSTR pOldDriverDirectory;
  89. } DRIVER_UPGRADE_INFO_1, *PDRIVER_UPGRADE_INFO_1;
  90. typedef struct _DRIVER_UPGRADE_INFO_2 {
  91. LPTSTR pPrinterName;
  92. LPTSTR pOldDriverDirectory;
  93. DWORD cVersion;
  94. LPTSTR pName;
  95. LPTSTR pEnvironment;
  96. LPTSTR pDriverPath;
  97. LPTSTR pDataFile;
  98. LPTSTR pConfigFile;
  99. LPTSTR pHelpFile;
  100. LPTSTR pDependentFiles;
  101. LPTSTR pMonitorName;
  102. LPTSTR pDefaultDataType;
  103. LPTSTR pszzPreviousNames;
  104. } DRIVER_UPGRADE_INFO_2, *PDRIVER_UPGRADE_INFO_2;
  105. BOOL WINAPI
  106. DrvUpgradePrinter(
  107. DWORD Level,
  108. LPBYTE pDriverUpgradeInfo
  109. );
  110. //
  111. // DrvDocumentEvent
  112. //
  113. //
  114. // Defines and proto-types for hooking GDI printer management functions
  115. //
  116. // return values: -1 means error, 0 means not supported function
  117. //
  118. // CreateDCPre must return > 0 or none of the others will be called.
  119. //
  120. //
  121. // CREATEDCPRE
  122. // return failure from CreateDC if this fails, CREATEDCPOST not called
  123. // bIC - TRUE if came from CreateIC
  124. // output devmode - this is the devmode that actualy gets passed to the
  125. // server side driver. Any data needed in EnablePDEV should be passed
  126. // as part of the DriverExtra.
  127. //
  128. // CREATEDCPOST
  129. // return value is ignored
  130. // the hdc will be 0 if something failed since CREATEDCPRE
  131. // The input buffer contains a pointer to the devmode returned in the
  132. // CREATEDCPRE output buffer
  133. //
  134. // RESETDCPRE
  135. // return failure from ResetDC if this fails, CREATEDCPOST not called
  136. //
  137. // RESETDCPOST
  138. // return value is ignored
  139. //
  140. // STARTDOCPRE
  141. // return failure form StartDoc if this fails, driver not called
  142. //
  143. // STARTDOCPOST
  144. // return failure form StartDoc if this fails, driver already called.
  145. // AbortDoc() called.
  146. //
  147. // STARTPAGE
  148. // return failure form EndPage if this fails, driver not called
  149. //
  150. // ENDPAGE
  151. // return value is ignored, DrvEndPage always called
  152. //
  153. // ENDDOCPRE
  154. // return value is ignored, DrvEndDoc always called
  155. //
  156. // ENDDOCPOST
  157. // return value is ignored, DrvEndDoc has alreadybeen called
  158. //
  159. // ABORTDOC
  160. // return value is ignored
  161. //
  162. // DELETEDC
  163. // return value is ignored
  164. //
  165. // EXTESCAPE
  166. // return value is ignored
  167. // The input buffer includes the ExtEscape escape value, size of input
  168. // buffer to ExtEscape and the input buffer passed in.
  169. // The output buffer is just the buffer that was passed to ExtEscape
  170. //
  171. // DOCUMENTEVENT_SPOOLED
  172. // This flag is added to the iEsc value if the document is being spooled
  173. // to a metafile rather than going direct. Note that if this bit is set
  174. //
  175. //
  176. #define DOCUMENTEVENT_EVENT(iEsc) (LOWORD(iEsc))
  177. #define DOCUMENTEVENT_FLAGS(iEsc) (HIWORD(iEsc))
  178. typedef struct _DOCEVENT_FILTER {
  179. UINT cbSize;
  180. UINT cElementsAllocated;
  181. UINT cElementsNeeded;
  182. UINT cElementsReturned;
  183. DWORD aDocEventCall[ANYSIZE_ARRAY];
  184. } DOCEVENT_FILTER, *PDOCEVENT_FILTER;
  185. //
  186. // Add structures usded for each DocumentEvent calls
  187. //
  188. typedef struct _DOCEVENT_CREATEDCPRE {
  189. PWSTR pszDriver;
  190. PWSTR pszDevice;
  191. PDEVMODEW pdm;
  192. BOOL bIC;
  193. } DOCEVENT_CREATEDCPRE, *PDCEVENT_CREATEDCPRE;
  194. typedef struct _DOCEVENT_ESCAPE {
  195. int iEscape;
  196. int cjInput;
  197. PVOID pvInData;
  198. } DOCEVENT_ESCAPE, *PDOCEVENT_ESCAPE;
  199. //
  200. // Escape codes for DrvDocumentEvent
  201. //
  202. #define DOCUMENTEVENT_FIRST 1 // Inclusive lower bound
  203. #define DOCUMENTEVENT_CREATEDCPRE 1 // in-pszDriver, pszDevice, pdm, bIC, out-ppdm
  204. #define DOCUMENTEVENT_CREATEDCPOST 2 // in-ppdm
  205. #define DOCUMENTEVENT_RESETDCPRE 3 // in-pszDriver, pszDevice, pdm, out-ppdm
  206. #define DOCUMENTEVENT_RESETDCPOST 4 // in-ppdm
  207. #define DOCUMENTEVENT_STARTDOC 5 // none
  208. #define DOCUMENTEVENT_STARTDOCPRE 5 // none
  209. #define DOCUMENTEVENT_STARTPAGE 6 // none
  210. #define DOCUMENTEVENT_ENDPAGE 7 // none
  211. #define DOCUMENTEVENT_ENDDOC 8 // none
  212. #define DOCUMENTEVENT_ENDDOCPRE 8 // none
  213. #define DOCUMENTEVENT_ABORTDOC 9 // none
  214. #define DOCUMENTEVENT_DELETEDC 10 // none
  215. #define DOCUMENTEVENT_ESCAPE 11 // in-iEsc, cjInBuf, inBuf, out-outBuf
  216. #define DOCUMENTEVENT_ENDDOCPOST 12 // none
  217. #define DOCUMENTEVENT_STARTDOCPOST 13 // none
  218. #define DOCUMENTEVENT_QUERYFILTER 14 // none
  219. #define DOCUMENTEVENT_LAST 15 // Non-inclusive upper bound
  220. #define DOCUMENTEVENT_SPOOLED 0x10000
  221. //
  222. // Return values for DrvDocumentEvent
  223. //
  224. #define DOCUMENTEVENT_SUCCESS 1
  225. #define DOCUMENTEVENT_UNSUPPORTED 0
  226. #define DOCUMENTEVENT_FAILURE -1
  227. int WINAPI
  228. DrvDocumentEvent(
  229. HANDLE hPrinter,
  230. HDC hdc,
  231. int iEsc,
  232. ULONG cbIn,
  233. PVOID pvIn,
  234. ULONG cbOut,
  235. PVOID pvOut
  236. );
  237. //
  238. // DrvPrinterEvent
  239. //
  240. //
  241. // DrvPrinterEvent are called by the print subsystem when events
  242. // happen that might be of interest to a printer driver
  243. // The only event which should be implemented in the driver
  244. // is PRITNER_EVENT_INITIALIZE so that default settings are created
  245. // for the printer.
  246. //
  247. // PRINTER_EVENT_CONFIGURATION_CHANGE
  248. // Reserve it for future use.Xerox is already using it.
  249. //
  250. // PRINTER_EVENT_ADD_CONNECTION
  251. // return value ignored
  252. // Called after a successful AddPrinterConnection API
  253. // in the context of the calling app
  254. // lParam NULL
  255. //
  256. // PRINTER_EVENT_DELETE_CONNECTION
  257. // return value ignored
  258. // Called Before DeletePrinterConnect API
  259. // in the context of the calling app
  260. // lParam NULL
  261. //
  262. // PRINTER_EVENT_INITIALIZE
  263. // Called when a printer is created for the driver to
  264. // initialize its registry settings
  265. // Called in the spooler process
  266. // lParam NULL
  267. //
  268. // PRINTER_EVENT_DELETE
  269. // Called when a printer is about to be deleted
  270. // Called in the spooler process
  271. // lParam NULL
  272. //
  273. // PRINTER_EVENT_CACHE_REFRESH
  274. // return value ignored
  275. // called in spooler process
  276. // No UI
  277. // called when spooler detects that something has
  278. // changed in the workstaion cache or when establishing
  279. // the cache.
  280. // allows driver to update any private cache data
  281. // ( such as font files etc. )
  282. //
  283. // PRINTER_EVENT_CACHE_DELETE
  284. // return value ignored
  285. // called in spooler process
  286. // No UI
  287. // called when spooler is deleting a cached printer
  288. // allows printer driver to delete anything it has
  289. // cached
  290. //
  291. // PRINTER_EVENT_ATTRIBUTES_CHANGED
  292. // return value ignored
  293. // No UI
  294. // Called when the printer attribute bits for a given
  295. // printer have changed. Allows the driver to respond
  296. // appropriately.
  297. // lParam is a pointer to a PRINTER_EVENT_ATTRIBUTES_INFO
  298. // structure.
  299. //
  300. // PRINTER_EVENT_FLAG_NO_UI
  301. // Do not bring up UI when this flag it ON
  302. //
  303. //
  304. // DrvPrinterEvent DriverEvent code
  305. //
  306. #define PRINTER_EVENT_CONFIGURATION_CHANGE 0
  307. #define PRINTER_EVENT_ADD_CONNECTION 1
  308. #define PRINTER_EVENT_DELETE_CONNECTION 2
  309. #define PRINTER_EVENT_INITIALIZE 3
  310. #define PRINTER_EVENT_DELETE 4
  311. #define PRINTER_EVENT_CACHE_REFRESH 5
  312. #define PRINTER_EVENT_CACHE_DELETE 6
  313. #define PRINTER_EVENT_ATTRIBUTES_CHANGED 7
  314. //
  315. // DrvPrinterEvent Flags
  316. //
  317. #define PRINTER_EVENT_FLAG_NO_UI 0x00000001
  318. //
  319. // lParam of PRINTER_EVENT_ATTRIBUTES_CHANGED points to this structure.
  320. //
  321. typedef struct _PRINTER_EVENT_ATTRIBUTES_INFO {
  322. DWORD cbSize;
  323. DWORD dwOldAttributes;
  324. DWORD dwNewAttributes;
  325. } PRINTER_EVENT_ATTRIBUTES_INFO, *PPRINTER_EVENT_ATTRIBUTES_INFO;
  326. BOOL WINAPI
  327. DrvPrinterEvent(
  328. LPWSTR pPrinterName,
  329. int DriverEvent,
  330. DWORD Flags,
  331. LPARAM lParam
  332. );
  333. //
  334. // DrvDriverEvent is called when any version of the printer driver is deleted.
  335. //
  336. #define DRIVER_EVENT_INITIALIZE 0x00000001
  337. #define DRIVER_EVENT_DELETE 0x00000002
  338. BOOL WINAPI
  339. DrvDriverEvent(
  340. DWORD dwDriverEvent,
  341. DWORD dwLevel,
  342. LPBYTE pDriverInfo,
  343. LPARAM lParam
  344. );
  345. // Print processor capabilities for the driver.
  346. #define BORDER_PRINT 0x00000000 // default
  347. #define NO_BORDER_PRINT 0x00000001
  348. #define BOOKLET_PRINT 0x00000002
  349. #define NO_COLOR_OPTIMIZATION 0x00000000 // default
  350. #define COLOR_OPTIMIZATION 0x00000001
  351. typedef struct _ATTRIBUTE_INFO_1 {
  352. DWORD dwJobNumberOfPagesPerSide;
  353. DWORD dwDrvNumberOfPagesPerSide;
  354. DWORD dwNupBorderFlags;
  355. DWORD dwJobPageOrderFlags;
  356. DWORD dwDrvPageOrderFlags;
  357. DWORD dwJobNumberOfCopies;
  358. DWORD dwDrvNumberOfCopies;
  359. } ATTRIBUTE_INFO_1, *PATTRIBUTE_INFO_1;
  360. typedef struct _ATTRIBUTE_INFO_2 {
  361. DWORD dwJobNumberOfPagesPerSide;
  362. DWORD dwDrvNumberOfPagesPerSide;
  363. DWORD dwNupBorderFlags;
  364. DWORD dwJobPageOrderFlags;
  365. DWORD dwDrvPageOrderFlags;
  366. DWORD dwJobNumberOfCopies;
  367. DWORD dwDrvNumberOfCopies;
  368. DWORD dwColorOptimization; // Added for monochrome optimization
  369. } ATTRIBUTE_INFO_2, *PATTRIBUTE_INFO_2;
  370. typedef struct _ATTRIBUTE_INFO_3 {
  371. DWORD dwJobNumberOfPagesPerSide;
  372. DWORD dwDrvNumberOfPagesPerSide;
  373. DWORD dwNupBorderFlags;
  374. DWORD dwJobPageOrderFlags;
  375. DWORD dwDrvPageOrderFlags;
  376. DWORD dwJobNumberOfCopies;
  377. DWORD dwDrvNumberOfCopies;
  378. DWORD dwColorOptimization; // Added for monochrome optimization
  379. short dmPrintQuality; // Added for monochrome optimization
  380. short dmYResolution; // Added for monochrome optimization
  381. } ATTRIBUTE_INFO_3, *PATTRIBUTE_INFO_3;
  382. //
  383. // DrvQueryJobAttributes is called by the spooler(print processor) to get information
  384. // about the printing options used with the job. These options include N-up and reverse
  385. // order printing.
  386. //
  387. BOOL WINAPI
  388. DrvQueryJobAttributes(
  389. HANDLE hPrinter,
  390. PDEVMODE pDevMode,
  391. DWORD dwLevel,
  392. LPBYTE lpAttributeInfo
  393. );
  394. //
  395. // DrvQueryColorProfile is called by the GDI (graphics device interface) to get information
  396. // about the default color profile for the given DEVMODE, used with ICM (image color
  397. // management).
  398. //
  399. BOOL WINAPI
  400. DrvQueryColorProfile(
  401. HANDLE hPrinter,
  402. PDEVMODEW pdevmode,
  403. ULONG ulQueryMode,
  404. VOID *pvProfileData,
  405. ULONG *pcbProfileData,
  406. FLONG *pflProfileData
  407. );
  408. // The value for ulQueryMode
  409. #define QCP_DEVICEPROFILE 0x0000
  410. #define QCP_SOURCEPROFILE 0x0001
  411. // The flags for pflProfileData.
  412. #define QCP_PROFILEMEMORY 0x0001 // The pvProfileData points the color profile data itself.
  413. #define QCP_PROFILEDISK 0x0002 // The pvProfileData points the color profile file name in Unicode.
  414. //
  415. // User Mode Printer Driver DLL,
  416. //
  417. // Note on hPrinter passed into DrvSplStartDoc() and subsequent
  418. // DrvSplxxx calls
  419. //
  420. //
  421. // A. If you have DrvSplxxxx calls in separate DLL and link it with
  422. // spoolss.lib.
  423. //
  424. // * The hPrinter will be valid for any call to the spooler, such as
  425. // WritePrinter(), GetPrinterData()
  426. //
  427. // * To do this you must
  428. //
  429. // 1. Have separate DLL for all DrvSplxxx functions.
  430. // 2. Put this DLL name into your dependency files (inf).
  431. // 3. link to spoolss.lib rather than winspool.lib
  432. // 4. Use SetPrinterData() with SPLPRINTER_USER_MODE_PRINTER_DRIVER
  433. // as key name, and this DLL name as data.
  434. // 5. Call any spooler functions linked from spoolss.lib
  435. //
  436. //
  437. //
  438. // B. If you have DrvSplxxx calls located in your printer driver UI DLL and
  439. // linked with winspool.lib
  440. //
  441. // * The hPrinter is NOT valid for any spooler calls, such as
  442. // WritePrinter(), GetPrinterData() from within the DrvSplxxx driver
  443. // functions.
  444. //
  445. // * To do any spooler call from inside of DrvSplxxxx function you must
  446. // do the following
  447. //
  448. // 1. hSpoolSS = LoadLibrary("spoolss.dll");
  449. // 2. pfn = GetProcAddress("WritePrinter") or whatever the spooler
  450. // functions you wish to call
  451. // 3. Call the pfn function pointer returned from GetProcAddress()
  452. // 4. FreeLibrary(hSpoolSS);
  453. //
  454. //
  455. // The A method is recommended.
  456. //
  457. //
  458. // If a UserModePrinterDriver DLL is created the following routines are
  459. // required or optional
  460. //
  461. // Required Routines
  462. // DrvSplStartDoc
  463. // DrvSplWritePrinter
  464. // DrvSplEndDoc
  465. // DrvSplClose
  466. //
  467. //
  468. // Optional Routines
  469. // DrvSplStart
  470. // DrvSplEndPage
  471. // DrvSplAbort
  472. //
  473. //
  474. HANDLE WINAPI
  475. DrvSplStartDoc(
  476. HANDLE hPrinter,
  477. DWORD JobId
  478. );
  479. BOOL WINAPI
  480. DrvSplWritePrinter(
  481. HANDLE hDriver,
  482. LPVOID pBuf,
  483. DWORD cbBuf,
  484. LPDWORD pcWritten
  485. );
  486. VOID WINAPI
  487. DrvSplEndDoc(
  488. HANDLE hDriver
  489. );
  490. VOID WINAPI
  491. DrvSplClose(
  492. HANDLE hDriver
  493. );
  494. BOOL WINAPI
  495. DrvSplStartPage(
  496. HANDLE hDriver
  497. );
  498. BOOL WINAPI
  499. DrvSplEndPage(
  500. HANDLE hDriver
  501. );
  502. VOID WINAPI
  503. DrvSplAbort(
  504. HANDLE hDriver
  505. );
  506. //
  507. // Printer Attribute
  508. // Use with SetPrinterData to define UMPD.DLL
  509. //
  510. #define SPLPRINTER_USER_MODE_PRINTER_DRIVER TEXT("SPLUserModePrinterDriver")
  511. #ifdef __cplusplus
  512. }
  513. #endif
  514. #endif /* !_WINDDIUI_ */