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.

217 lines
5.9 KiB

  1. // WIA.h: interface for the CWIA class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_WIA_H__D5024620_FCB4_11D2_B819_009027226441__INCLUDED_)
  5. #define AFX_WIA_H__D5024620_FCB4_11D2_B819_009027226441__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <afxtempl.h> // needed for CTypePtrList
  10. #define DEFINE_IMAGE_FORMATS
  11. #include "wia.h" // WIA device manager
  12. #include "callback.h" // needed for registering callbacks
  13. #include "cdib.h" // needed for DIB data
  14. #include "datacallback.h" // needed for data callback
  15. #include "sti.h" // needed for STI stuff
  16. #include "eventcallback.h" // needed for event callback
  17. #define MIN_PROPID 2
  18. #define IDT_GETDATA 0
  19. #define IDT_GETBANDEDDATA 1
  20. // Item tree struct def
  21. typedef struct WIAITEMTREENODEtag
  22. {
  23. IWiaItem* pIWiaItem;
  24. long ParentID;
  25. }WIAITEMTREENODE;
  26. typedef struct WIADEVICENODEtag
  27. {
  28. BSTR bstrDeviceID;
  29. BSTR bstrDeviceName;
  30. BSTR bstrServerName;
  31. }WIADEVICENODE;
  32. typedef struct WIAITEMINFONODEtag
  33. {
  34. BSTR bstrPropertyName;
  35. PROPSPEC PropSpec;
  36. PROPVARIANT PropVar;
  37. unsigned long AccessFlags;
  38. }WIAITEMINFONODE;
  39. class CWIA
  40. {
  41. public:
  42. CWIA();
  43. virtual ~CWIA();
  44. HRESULT Initialize();
  45. void Shutdown();
  46. void Restart();
  47. //
  48. // helpers
  49. //
  50. HRESULT ReadPropStr(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, BSTR *pbstr);
  51. HRESULT WritePropStr(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, BSTR bstr);
  52. HRESULT ReadPropLong(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, LONG *plval);
  53. HRESULT WritePropLong(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, LONG lVal);
  54. HRESULT WritePropGUID(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, GUID guidVal);
  55. BOOL MoveTempFile(LPWSTR pwszTempFileName, LPCTSTR TargetFileName);
  56. void EnableMessageBoxErrorReport(BOOL bEnable);
  57. BOOL IsValidItem(IWiaItem *pIWiaItem);
  58. //
  59. // Image Acquistion
  60. //
  61. HRESULT DoIWiaDataGetDataTransfer(IWiaItem *pIWiaItem,
  62. DWORD Tymed,
  63. GUID ClipboardFormat);
  64. HRESULT DoIWiaDataBandedTransfer(IWiaItem *pIWiaItem,
  65. DWORD Tymed,
  66. GUID ClipboardFormat);
  67. HRESULT DoGetImageDlg(HWND hParentWnd,
  68. long DeviceType,
  69. long Flags,
  70. long Intent,
  71. long Tymed,
  72. GUID ClipboardFormat);
  73. void SetFileName(CString Filename);
  74. void SetPreviewWindow(HWND hWnd);
  75. CDib* GetDIB();
  76. HWND m_hPreviewWnd;
  77. //
  78. // Item operations
  79. //
  80. HRESULT SavePropStreamToFile(char* pFileName, IWiaItem* pIWiaItem);
  81. HRESULT ReadPropStreamFromFile(char* pFileName, IWiaItem* pIWiaItem);
  82. HRESULT GetSetPropStreamTest(IWiaItem* pIWiaItem);
  83. HRESULT CreateWIADevice(BSTR bstrDeviceID);
  84. HRESULT ReEnumerateItems();
  85. HRESULT EnumerateAllWIADevices();
  86. HRESULT EnumerateSupportedFormats(IWiaItem* pIRootItem);
  87. HRESULT CreateItemPropertyInformationList(IWiaItem* pIWiaItem);
  88. HRESULT AnalyzeItem(IWiaItem* pIWiaItem);
  89. HRESULT CreateChildItem(IWiaItem *pIWiaItem);
  90. CPtrList* GetItemTreeList();
  91. CPtrList* GetSupportedFormatList();
  92. IWiaItem* GetRootIWiaItem();
  93. long GetMinBufferSize(IWiaItem *pIWiaItem);
  94. BOOL IsRoot(POSITION Position);
  95. BOOL IsFolder(POSITION Position);
  96. WIAITEMTREENODE* GetAt(POSITION Position);
  97. void RemoveAt(POSITION Position);
  98. int GetRootItemType();
  99. //
  100. // event registration
  101. //
  102. HRESULT RegisterForConnectEvents(CEventCallback* pConnectEventCB);
  103. HRESULT UnRegisterForConnectEvents(CEventCallback* pConnectEventCB);
  104. HRESULT RegisterForDisConnectEvents(CEventCallback* pDisConnectEventCB);
  105. HRESULT UnRegisterForDisConnectEvents(CEventCallback* pDisConnectEventCB);
  106. //
  107. // Automation and UI initialization only
  108. //
  109. //
  110. // Device ID Enumerators
  111. //
  112. void Auto_ResetDeviceEnumerator();
  113. WIADEVICENODE* Auto_GetNextDevice();
  114. long GetWIADeviceCount();
  115. //
  116. // IWIAItem Enumerators
  117. //
  118. IWiaItem* Auto_GetNextItem();
  119. void Auto_ResetItemEnumerator();
  120. long GetWIAItemCount();
  121. //
  122. // Item Property Info Enumerators
  123. //
  124. WIAITEMINFONODE* Auto_GetNextItemPropertyInfo();
  125. void Auto_ResetItemPropertyInfoEnumerator();
  126. long GetWIAItemProperyInfoCount();
  127. //
  128. // Supported WIAFormatInfo Enumerators
  129. //
  130. WIA_FORMAT_INFO* Auto_GetNextFormatEtc();
  131. void Auto_ResetFormatEtcEnumerator();
  132. private:
  133. //
  134. // Cleanup
  135. //
  136. void Cleanup();
  137. void DeleteWIADeviceList();
  138. void DeleteActiveTreeList();
  139. void DeleteSupportedFormatList();
  140. void DeleteItemPropertyInfoList();
  141. //
  142. // Enumeration / Initialization
  143. //
  144. HRESULT EnumerateAllItems(IWiaItem *pIRootItem);
  145. HRESULT EnumNextLevel(IEnumWiaItem *pEnumItem,int ParentID);
  146. HRESULT CreateWIADeviceManager();
  147. //
  148. // private member variables
  149. //
  150. CTypedPtrList<CPtrList, WIAITEMTREENODE*> m_ActiveTreeList;
  151. CTypedPtrList<CPtrList, WIADEVICENODE*> m_WIADeviceList;
  152. CTypedPtrList<CPtrList, WIA_FORMAT_INFO*> m_SupportedFormatList;
  153. CTypedPtrList<CPtrList, WIAITEMINFONODE*> m_ItemPropertyInfoList;
  154. IWiaDevMgr* m_pIWiaDevMgr;
  155. IWiaItem* m_pRootIWiaItem;
  156. CDib* m_pDIB;
  157. CString m_FileName;
  158. CString m_ApplicationName;
  159. POSITION m_CurrentActiveTreeListPosition;
  160. POSITION m_CurrentDeviceListPosition;
  161. POSITION m_CurrentFormatEtcListPosition;
  162. POSITION m_CurrentItemProperyInfoListPosition;
  163. BOOL m_bMessageBoxReport;
  164. //
  165. // logging
  166. //
  167. void StressStatus(CString status);
  168. void StressStatus(CString status,HRESULT hResult);
  169. };
  170. #endif // !defined(AFX_WIA_H__D5024620_FCB4_11D2_B819_009027226441__INCLUDED_)