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.

164 lines
4.6 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: CHOOSDLG.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 5/12/1998
  12. *
  13. * DESCRIPTION: Declarations for the WIA device selection dialog box
  14. *
  15. *******************************************************************************/
  16. #ifndef __CHOOSDLG_H
  17. #define __CHOOSDLG_H
  18. #include <windows.h>
  19. #include <objbase.h>
  20. #include <wia.h>
  21. #include <simstr.h>
  22. #include <devlist.h>
  23. #include <wiaseld.h>
  24. #define PWM_WIA_EVENT (WM_USER+111)
  25. struct CChooseDeviceDialogParams
  26. {
  27. SELECTDEVICEDLG *pSelectDeviceDlg;
  28. CDeviceList *pDeviceList;
  29. };
  30. class CChooseDeviceDialog
  31. {
  32. private:
  33. CChooseDeviceDialogParams *m_pChooseDeviceDialogParams;
  34. HWND m_hWnd;
  35. HFONT m_hBigFont;
  36. CComPtr<IUnknown> m_pDisconnectEvent;
  37. CComPtr<IUnknown> m_pConnectEvent;
  38. private:
  39. //
  40. // No implementation
  41. //
  42. CChooseDeviceDialog(void);
  43. CChooseDeviceDialog( const CChooseDeviceDialog & );
  44. CChooseDeviceDialog &operator=( const CChooseDeviceDialog & );
  45. public:
  46. static INT_PTR CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  47. private:
  48. //
  49. // This is stored as data with each icon
  50. //
  51. class CDeviceInfo
  52. {
  53. private:
  54. CComPtr<IWiaPropertyStorage> m_pPropertyStorage;
  55. CComPtr<IWiaItem> m_pRootItem;
  56. private:
  57. //
  58. // No implementation
  59. //
  60. CDeviceInfo &operator=( const CDeviceInfo & );
  61. CDeviceInfo( const CDeviceInfo & );
  62. public:
  63. CDeviceInfo( IUnknown *pIUnknown=NULL )
  64. {
  65. Initialize(pIUnknown);
  66. }
  67. ~CDeviceInfo(void)
  68. {
  69. m_pPropertyStorage.Release();
  70. }
  71. IWiaPropertyStorage *WiaPropertyStorage(void)
  72. {
  73. return m_pPropertyStorage.p;
  74. }
  75. HRESULT Initialize( IUnknown *pIUnknown )
  76. {
  77. m_pPropertyStorage = NULL;
  78. if (!pIUnknown)
  79. {
  80. return E_POINTER;
  81. }
  82. return pIUnknown->QueryInterface( IID_IWiaPropertyStorage, (void**)&m_pPropertyStorage );
  83. }
  84. bool GetProperty( PROPID propId, CSimpleStringWide &strPropertyValue )
  85. {
  86. return PropStorageHelpers::GetProperty( m_pPropertyStorage, propId, strPropertyValue );
  87. }
  88. bool GetProperty( PROPID propId, LONG &nValue )
  89. {
  90. return PropStorageHelpers::GetProperty( m_pPropertyStorage, propId, nValue );
  91. }
  92. void RootItem( IWiaItem *pRootItem )
  93. {
  94. m_pRootItem = pRootItem;
  95. }
  96. IWiaItem *RootItem(void)
  97. {
  98. return m_pRootItem;
  99. }
  100. };
  101. private:
  102. //
  103. // Only constructor and destructor
  104. //
  105. explicit CChooseDeviceDialog( HWND hwnd );
  106. ~CChooseDeviceDialog(void);
  107. //
  108. // Message handlers
  109. //
  110. LRESULT OnInitDialog( WPARAM, LPARAM );
  111. LRESULT OnNotify( WPARAM wParam, LPARAM lParam );
  112. LRESULT OnDestroy( WPARAM, LPARAM );
  113. LRESULT OnCommand( WPARAM wParam, LPARAM lParam );
  114. LRESULT OnDblClkDeviceList( WPARAM wParam, LPARAM lParam );
  115. LRESULT OnItemChangedDeviceList( WPARAM wParam, LPARAM lParam );
  116. LRESULT OnItemDeletedDeviceList( WPARAM, LPARAM lParam );
  117. LRESULT OnWiaEvent( WPARAM wParam, LPARAM lParam );
  118. LRESULT OnHelp( WPARAM, LPARAM );
  119. LRESULT OnContextMenu( WPARAM, LPARAM );
  120. LRESULT OnSysColorChange( WPARAM, LPARAM );
  121. //
  122. // WM_COMMAND handlers
  123. //
  124. void OnProperties( WPARAM wParam, LPARAM lParam );
  125. void OnOk( WPARAM wParam, LPARAM lParam );
  126. void OnCancel( WPARAM wParam, LPARAM lParam );
  127. //
  128. // Helper functions
  129. //
  130. int FindItemMatch( const CSimpleStringWide &str );
  131. bool SetSelectedItem( int iItem );
  132. HICON LoadDeviceIcon( CDeviceInfo *pdi );
  133. int GetFirstSelectedDevice(void);
  134. CDeviceInfo *GetDeviceInfoFromList( int iIndex );
  135. bool AddDevices(void);
  136. BOOL AddDevice( IWiaPropertyStorage *pIWiaPropertyStorage, int iDevNo );
  137. void UpdateDeviceInformation(void);
  138. HRESULT CreateDeviceIfNecessary( CDeviceInfo *pDevInfo, HWND hWndParent, IWiaItem **ppRootItem, BSTR *pbstrDeviceId );
  139. public:
  140. static HRESULT CreateWiaDevice( IWiaDevMgr *pWiaDevMgr, IWiaPropertyStorage *pWiaPropertyStorage, HWND hWndParent, IWiaItem **ppWiaRootItem, BSTR *pbstrDeviceId );
  141. };
  142. #endif