forked from zodiacon/ObjectExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewFactory.cpp
107 lines (97 loc) · 3.04 KB
/
ViewFactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "pch.h"
#include "resource.h"
#include "ViewFactory.h"
#include "ObjectTypesView.h"
#include "ObjectManagerView.h"
#include "HandlesView.h"
#include "ObjectsView.h"
#include "ZombieProcessesView.h"
ViewFactory& ViewFactory::Get() {
static ViewFactory factory;
return factory;
}
bool ViewFactory::Init(IMainFrame* frame, CCustomTabView& tabs) {
m_pFrame = frame;
m_tabs = &tabs;
UINT icons[] = {
IDI_TYPES, IDI_PACKAGE, IDI_MAGNET, IDI_MAGNET2, IDI_OBJECTS,
IDI_PROCESS_ZOMBIE, IDI_THREAD_ZOMBIE,
};
CImageList images;
images.Create(16, 16, ILC_COLOR32 | ILC_MASK, 4, 4);
for (auto icon : icons)
images.AddIcon(AtlLoadIconImage(icon, 0, 16, 16));
tabs.SetImageList(images);
ViewIconType iconTypes[] = {
ViewIconType::ZombieProcess,
};
for (auto icon : iconTypes) {
int n = images.AddIcon(AtlLoadIconImage((UINT)icon, 0, 16, 16));
m_tabIcons.insert({ icon, n });
}
return true;
}
IView* ViewFactory::CreateView(ViewType type, DWORD pid, PCWSTR sparam) {
DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
IView* view{ nullptr };
int image = -1;
switch (type) {
case ViewType::ObjectTypes:
{
auto p = new CObjectTypesView(m_pFrame);
p->Create(*m_tabs, CWindow::rcDefault, nullptr, style, 0);
image = 0;
view = p;
break;
}
case ViewType::ObjectManager:
{
auto p = new CObjectManagerView(m_pFrame);
p->Create(*m_tabs, CWindow::rcDefault, nullptr, style, 0);
image = 1;
view = p;
break;
}
case ViewType::ZombieProcesses:
case ViewType::ZombieThreads:
{
auto p = new CZombieProcessesView(m_pFrame, type == ViewType::ZombieProcesses);
p->Create(*m_tabs, CWindow::rcDefault, nullptr, style, 0);
image = type == ViewType::ZombieProcesses ? 5 : 6;
view = p;
break;
}
case ViewType::AllHandles:
case ViewType::ProcessHandles:
case ViewType::HandlesOfType:
{
auto p = new CHandlesView(m_pFrame, pid, sparam);
p->Create(*m_tabs, CWindow::rcDefault, nullptr, style);
image = type == ViewType::AllHandles ? 2 : 3;
view = p;
break;
}
case ViewType::Objects:
{
auto p = new CObjectsView(m_pFrame, sparam);
p->Create(*m_tabs, CWindow::rcDefault, nullptr, style);
image = 4;
view = p;
break;
}
}
if(view)
m_tabs->AddPage(view->GetHwnd(), view->GetTitle(), image, view);
return view;
}
void ViewFactory::SetTabIcon(IView* view, ViewIconType iconType) {
int count = m_tabs->GetPageCount();
int i;
for (i = 0; i < count; i++) {
if (m_tabs->GetPageData(i) == view) {
m_tabs->SetPageImage(i, m_tabIcons[iconType]);
break;
}
}
ATLASSERT(i < count);
}