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