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.

128 lines
3.9 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: DEVPROP.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 8/31/2000
  12. *
  13. * DESCRIPTION: Identify a scanner's characteristics
  14. *
  15. *******************************************************************************/
  16. #include <wia.h>
  17. #include <uicommon.h>
  18. namespace ScannerProperties
  19. {
  20. enum
  21. {
  22. HasFlatBed = 0x00000001,
  23. HasDocumentFeeder = 0x00000002,
  24. SupportsPreview = 0x00000008,
  25. SupportsPageSize = 0x00000010,
  26. };
  27. LONG GetDeviceProps( IWiaItem *pWiaRootItem )
  28. {
  29. WIA_PUSHFUNCTION(TEXT("ScannerProperties::GetDeviceProps()"));
  30. LONG lResult = 0;
  31. //
  32. // If the scanner has document handling and supports FEEDER, it has an ADF.
  33. //
  34. LONG nDocumentHandlingSelect = 0;
  35. if (PropStorageHelpers::GetPropertyFlags( pWiaRootItem, WIA_DPS_DOCUMENT_HANDLING_SELECT, nDocumentHandlingSelect) && (nDocumentHandlingSelect & FEEDER))
  36. {
  37. //
  38. // If the device has a feeder with no maximum length, it is a sheet feeder.
  39. //
  40. LONG nVerticalFeederSize = 0;
  41. if (PropStorageHelpers::GetProperty( pWiaRootItem, WIA_DPS_VERTICAL_SHEET_FEED_SIZE, nVerticalFeederSize ) && (nVerticalFeederSize != 0))
  42. {
  43. lResult |= HasDocumentFeeder;
  44. lResult |= SupportsPageSize;
  45. }
  46. else
  47. {
  48. lResult |= HasDocumentFeeder;
  49. }
  50. }
  51. //
  52. // If the scanner has a vertical bed size, it has a flatbed
  53. //
  54. LONG nVerticalBedSize = 0;
  55. if (PropStorageHelpers::GetProperty( pWiaRootItem, WIA_DPS_VERTICAL_BED_SIZE, nVerticalBedSize ) && (nVerticalBedSize != 0))
  56. {
  57. lResult |= HasFlatBed;
  58. lResult |= SupportsPreview;
  59. }
  60. //
  61. // If the driver specifically tells us it doesn't support previewing, turn it off
  62. //
  63. LONG nShowPreview = 0;
  64. if (PropStorageHelpers::GetProperty( pWiaRootItem, WIA_DPS_SHOW_PREVIEW_CONTROL, nShowPreview ) && (WIA_DONT_SHOW_PREVIEW_CONTROL == nShowPreview))
  65. {
  66. lResult &= ~SupportsPreview;
  67. }
  68. //
  69. // debug print an English string describing the properties
  70. //
  71. #if defined(DBG)
  72. #define ENTRY(x) { x, #x }
  73. static struct
  74. {
  75. LONG nFlag;
  76. CHAR *strName;
  77. } dbgFlags[] =
  78. {
  79. ENTRY(HasFlatBed),
  80. ENTRY(HasDocumentFeeder),
  81. ENTRY(SupportsPreview),
  82. ENTRY(SupportsPageSize)
  83. };
  84. CSimpleStringAnsi strProps;
  85. for (int i=0;i<ARRAYSIZE(dbgFlags);i++)
  86. {
  87. if (lResult & dbgFlags[i].nFlag)
  88. {
  89. if (strProps.Length())
  90. {
  91. strProps.Concat("|");
  92. }
  93. strProps.Concat(dbgFlags[i].strName);
  94. }
  95. }
  96. WIA_TRACE((TEXT("Device Properties: %hs"), strProps.String() ));
  97. #endif
  98. return lResult;
  99. }
  100. inline IsAScrollFedScanner( IWiaItem *pWiaRootItem )
  101. {
  102. LONG nDeviceProps = GetDeviceProps(pWiaRootItem);
  103. return ((nDeviceProps & HasDocumentFeeder) && !(nDeviceProps & SupportsPageSize));
  104. }
  105. inline IsAFlatbedScanner( IWiaItem *pWiaRootItem )
  106. {
  107. LONG nDeviceProps = GetDeviceProps(pWiaRootItem);
  108. return ((nDeviceProps & HasFlatBed) && (nDeviceProps & SupportsPreview));
  109. }
  110. inline IsAnADFAndFlatbed( IWiaItem *pWiaRootItem )
  111. {
  112. LONG nDeviceProps = GetDeviceProps(pWiaRootItem);
  113. return ((nDeviceProps & HasFlatBed) && (nDeviceProps & HasDocumentFeeder));
  114. }
  115. }