1c2c66affSColin Finck #pragma once 2c2c66affSColin Finck #include "DeviceNode.h" 3c2c66affSColin Finck #include "ClassNode.h" 4c2c66affSColin Finck #include "RootNode.h" 5c2c66affSColin Finck 6c2c66affSColin Finck enum ViewType 7c2c66affSColin Finck { 8c2c66affSColin Finck DevicesByType, 9c2c66affSColin Finck DevicesByConnection, 10c2c66affSColin Finck ResourcesByType, 11c2c66affSColin Finck ResourcesByConnection 12c2c66affSColin Finck }; 13c2c66affSColin Finck 14c2c66affSColin Finck 15c2c66affSColin Finck class CDeviceView 16c2c66affSColin Finck { 17c2c66affSColin Finck 18c2c66affSColin Finck HWND m_hMainWnd; 19c2c66affSColin Finck HWND m_hTreeView; 20c2c66affSColin Finck HWND m_hPropertyDialog; 21c2c66affSColin Finck HMENU m_hMenu; 22c2c66affSColin Finck ViewType m_ViewType; 23c2c66affSColin Finck HTREEITEM m_hTreeRoot; 24c2c66affSColin Finck bool m_ShowHidden; 25c2c66affSColin Finck 26c2c66affSColin Finck CRootNode *m_RootNode; 27c2c66affSColin Finck CAtlList<CClassNode *> m_ClassNodeList; 28c2c66affSColin Finck CAtlList<CDeviceNode *> m_DeviceNodeList; 29c2c66affSColin Finck SP_CLASSIMAGELIST_DATA m_ImageListData; 30c2c66affSColin Finck 31c2c66affSColin Finck public: 32c2c66affSColin Finck CDeviceView( 33c2c66affSColin Finck HWND hMainWnd 34c2c66affSColin Finck ); 35c2c66affSColin Finck 36c2c66affSColin Finck ~CDeviceView(void); 37c2c66affSColin Finck 38c2c66affSColin Finck bool Initialize(); 39c2c66affSColin Finck bool Uninitialize(); 40c2c66affSColin Finck 41c2c66affSColin Finck LRESULT OnSize( 42c2c66affSColin Finck _In_ int x, 43c2c66affSColin Finck _In_ int y, 44c2c66affSColin Finck _In_ int cx, 45c2c66affSColin Finck _In_ int cy 46c2c66affSColin Finck ); 47c2c66affSColin Finck 48*5831427eSJesús Sanz del Rey LRESULT OnDoubleClick( 49*5831427eSJesús Sanz del Rey _In_ LPNMHDR NmHdr 50*5831427eSJesús Sanz del Rey ); 51*5831427eSJesús Sanz del Rey 52c2c66affSColin Finck LRESULT OnRightClick( 53c2c66affSColin Finck _In_ LPNMHDR NmHdr 54c2c66affSColin Finck ); 55c2c66affSColin Finck 56c2c66affSColin Finck LRESULT OnContextMenu( 57c2c66affSColin Finck _In_ LPARAM lParam 58c2c66affSColin Finck ); 59c2c66affSColin Finck 60c2c66affSColin Finck LRESULT OnAction( 61c2c66affSColin Finck UINT Action 62c2c66affSColin Finck ); 63c2c66affSColin Finck 64c2c66affSColin Finck VOID Refresh( 65c2c66affSColin Finck _In_ ViewType Type, 66c2c66affSColin Finck _In_ bool ScanForChanges, 67c2c66affSColin Finck _In_ bool UpdateView 68c2c66affSColin Finck ); 69c2c66affSColin Finck 70c2c66affSColin Finck VOID DisplayPropertySheet(); 71c2c66affSColin Finck VOID SetFocus(); 72c2c66affSColin Finck SetHiddenDevices(_In_ bool ShowHidden)73c2c66affSColin Finck VOID SetHiddenDevices(_In_ bool ShowHidden) 74c2c66affSColin Finck { 75c2c66affSColin Finck m_ShowHidden = ShowHidden; 76c2c66affSColin Finck } 77c2c66affSColin Finck GetCurrentView()78c2c66affSColin Finck ViewType GetCurrentView() { return m_ViewType; } 79c2c66affSColin Finck 80c2c66affSColin Finck bool CreateActionMenu( 81c2c66affSColin Finck _In_ HMENU OwnerMenu, 82c2c66affSColin Finck _In_ bool MainMenu 83c2c66affSColin Finck ); 84c2c66affSColin Finck 85c2c66affSColin Finck CNode* GetSelectedNode( 86c2c66affSColin Finck ); 87c2c66affSColin Finck 88c2c66affSColin Finck bool SelDeviceIsStarted(); 89c2c66affSColin Finck bool SelDeviceIsInstalled(); 90c2c66affSColin Finck 91c2c66affSColin Finck private: 92c2c66affSColin Finck bool AddRootDevice(); 93c2c66affSColin Finck 94c2c66affSColin Finck bool RefreshDeviceList(); 95c2c66affSColin Finck 96c2c66affSColin Finck static unsigned int __stdcall RefreshThread( 97c2c66affSColin Finck void *Param 98c2c66affSColin Finck ); 99c2c66affSColin Finck 100c2c66affSColin Finck bool ListDevicesByConnection( 101c2c66affSColin Finck ); 102c2c66affSColin Finck bool ListDevicesByType( 103c2c66affSColin Finck ); 104c2c66affSColin Finck 105c2c66affSColin Finck bool GetNextClass( 106c2c66affSColin Finck _In_ ULONG ClassIndex, 107c2c66affSColin Finck _Out_ LPGUID ClassGuid, 108c2c66affSColin Finck _Out_ HDEVINFO *hDevInfo 109c2c66affSColin Finck ); 110c2c66affSColin Finck 111c2c66affSColin Finck bool RecurseChildDevices( 112c2c66affSColin Finck _In_ DEVINST ParentDevice, 113c2c66affSColin Finck _In_ HTREEITEM hParentTreeItem 114c2c66affSColin Finck ); 115c2c66affSColin Finck 116c2c66affSColin Finck bool EnableSelectedDevice( 117c2c66affSColin Finck _In_ bool Enable, 118c2c66affSColin Finck _Out_ bool &NeedsReboot 119c2c66affSColin Finck ); 120c2c66affSColin Finck 121c2c66affSColin Finck bool UpdateSelectedDevice( 122c2c66affSColin Finck _Out_ bool &NeedsReboot 123c2c66affSColin Finck ); 124c2c66affSColin Finck 125c2c66affSColin Finck bool UninstallSelectedDevice( 126c2c66affSColin Finck ); 127c2c66affSColin Finck 128c2c66affSColin Finck bool RunAddHardwareWizard( 129c2c66affSColin Finck ); 130c2c66affSColin Finck 131c2c66affSColin Finck bool GetChildDevice( 132c2c66affSColin Finck _In_ DEVINST ParentDevInst, 133c2c66affSColin Finck _Out_ PDEVINST DevInst 134c2c66affSColin Finck ); 135c2c66affSColin Finck 136c2c66affSColin Finck bool GetSiblingDevice( 137c2c66affSColin Finck _In_ DEVINST PrevDevice, 138c2c66affSColin Finck _Out_ PDEVINST DevInst 139c2c66affSColin Finck ); 140c2c66affSColin Finck 141c2c66affSColin Finck HTREEITEM InsertIntoTreeView( 142c2c66affSColin Finck _In_opt_ HTREEITEM hParent, 143c2c66affSColin Finck _In_ CNode *Node 144c2c66affSColin Finck ); 145c2c66affSColin Finck 146c2c66affSColin Finck void BuildActionMenuForNode( 147c2c66affSColin Finck _In_ HMENU OwnerMenu, 148c2c66affSColin Finck _In_ CNode *Node, 149c2c66affSColin Finck _In_ bool MainMenu 150c2c66affSColin Finck ); 151c2c66affSColin Finck 152c2c66affSColin Finck HTREEITEM RecurseFindDevice( 153c2c66affSColin Finck _In_ HTREEITEM hParentItem, 154c2c66affSColin Finck _In_ CNode *Node 155c2c66affSColin Finck ); 156c2c66affSColin Finck 157c2c66affSColin Finck void SelectNode( 158c2c66affSColin Finck _In_ CNode *Node 159c2c66affSColin Finck ); 160c2c66affSColin Finck 161c2c66affSColin Finck void EmptyDeviceView( 162c2c66affSColin Finck ); 163c2c66affSColin Finck 164c2c66affSColin Finck CNode* GetNode( 165c2c66affSColin Finck _In_ LPTV_ITEMW TvItem 166c2c66affSColin Finck ); 167c2c66affSColin Finck 168c2c66affSColin Finck CClassNode* GetClassNode( 169c2c66affSColin Finck _In_ LPGUID ClassGuid 170c2c66affSColin Finck ); 171c2c66affSColin Finck CDeviceNode* GetDeviceNode( 172c2c66affSColin Finck _In_ DEVINST Device 173c2c66affSColin Finck ); 174c2c66affSColin Finck void EmptyLists( 175c2c66affSColin Finck ); 176c2c66affSColin Finck }; 177c2c66affSColin Finck 178