MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / AddNode

Method AddNode

WinArk/WindowsView.cpp:228–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228CTreeItem CWindowsView::AddNode(HWND hWnd, HTREEITEM hParent) {
229 CString text, name;
230 CWindow win(hWnd);
231 m_TotalWindows++;
232 if (win.IsWindowVisible())
233 m_TotalVisibleWindows++;
234
235 if (m_DesktopNode) {
236 if (::GetAncestor(hWnd, GA_PARENT) == (HWND)m_DesktopNode.GetData())
237 m_TopLevelWindows++;
238
239 if (!m_ShowHiddenWindows && !win.IsWindowVisible())
240 return nullptr;
241 win.GetWindowText(name);
242 if (!m_ShowNoTitleWindows && name.IsEmpty())
243 return nullptr;
244 }
245
246 if (name.GetLength() > 64)
247 name = name.Left(64) + L"...";
248 if (!name.IsEmpty())
249 name = L"[" + name + L"]";
250 WCHAR className[64] = { 0 };
251 ::GetClassName(hWnd, className, _countof(className));
252 text.Format(L"0x%zX (%s) %s", (DWORD_PTR)hWnd, className, (PCWSTR)name);
253
254 HICON hIcon{ nullptr };
255 int image = 0;
256 if ((win.GetStyle() & WS_CHILD) == 0) {
257 // ��������ڣ��Ͳ���map
258 if (auto it = s_IconMap.find(hWnd); it == s_IconMap.end()) {
259 hIcon = WindowHelper::GetWindowOrProcessIcon(hWnd);
260 if (hIcon) {
261 s_IconMap.insert({ hWnd,image = s_Images.AddIcon(hIcon) });
262 }
263 }
264 else {
265 image = it->second;
266 }
267 }
268
269 auto node = m_Tree.InsertItem(text, image, image, hParent, TVI_LAST);
270 node.SetData((DWORD_PTR)hWnd);
271 m_WindowsMap.insert({ hWnd,node });
272
273 if (!win.IsWindowVisible())
274 node.SetState(TVIS_CUT, TVIS_CUT);
275
276 if (m_DesktopNode && win.GetWindow(GW_CHILD)) {
277 // add a "plus" button
278 node.AddTail(L"*", 0);
279 }
280 return node;
281}
282
283BOOL CWindowsView::AddChildNode(HWND hChild) {
284 if (::GetAncestor(hChild, GA_PARENT) == (HWND)m_Tree.GetItemData(m_hCurrentNode)) {

Callers 1

InitTreeMethod · 0.80

Calls 6

IsEmptyMethod · 0.80
InsertItemMethod · 0.80
SetDataMethod · 0.80
GetDataMethod · 0.45
GetLengthMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected