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