home *** CD-ROM | disk | FTP | other *** search
- // instview.cpp
- //
- // Created 01/14/99
- //
- // (C)Copyright 1999 Microsoft Corporation, All rights reserved.
- //
-
- #include "pch.hpp"
- #pragma hdrstop
-
- #include "instview.hpp"
- #include "hpmonmgr.hpp"
-
-
- LRESULT CALLBACK ClassInstancesViewer::WndProc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_NOTIFY:
- {
- LPNMHDR pnmh = (NMHDR*)lParam;
- switch (pnmh->code)
- {
- case TVN_ITEMEXPANDING:
- case TVN_ITEMEXPANDED:
- {
- NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
- TV_ITEM *ptvi = &pnmtv->itemNew;
- if (ptvi->hItem == m_htiroot)
- return BaseWndProc(wnd, msg, wParam, lParam);
- }
- break;
- }
- }
- break;
- }
-
- return ObjectViewer::WndProc(wnd, msg, wParam, lParam);
- }
-
-
- BOOL ClassInstancesViewer::GetItemText (HTREEITEM hti, PSTR &psztext, int &cchmaxtext)
- {
- BOOL result = ObjectViewer::GetItemText(hti, psztext, cchmaxtext);
-
- if (result && hti == m_htiroot)
- {
- int len = strlen(psztext);
- static CHAR prefix[] = "Instances of ";
- int prefixlen = ARRAY_ELEMENTS(prefix)-1;
- if (len+prefixlen < cchmaxtext)
- {
- MoveMemory(psztext+prefixlen, psztext, len+1);
- CopyMemory(psztext, prefix, prefixlen);
- }
- }
-
- return result;
- }
-
-
- //static
- int ClassInstancesViewer::PopulateInstancesCB (ID id, ObjectID vmid, PVOID token)
- {
- ClassInstancesViewer *civ = (ClassInstancesViewer*)token;
-
- if (id == NULL)
- {
- ASSERT(vmid != NULL);
- id = (OBJID)civ->m_mgr->LookupID(vmid);
- }
-
- BOOL result;
-
- if (id != NULL)
- result = (civ->AddTreeItemForID(civ->m_htiroot, id) != NULL);
- else
- result = (civ->AddTreeItemForObject(civ->m_htiroot, vmid) != NULL);
-
- if (result)
- TreeView_Expand(civ->m_htree, civ->m_htiroot, TVE_EXPAND);
-
- return 1;
- }
-
-
- BOOL ClassInstancesViewer::Initialize (HeapMonitorManager *mgr, CLASSID cls)
- {
- BOOL result;
-
- result = OVInitialize(mgr, "Class Instances");
- if (result)
- {
- result = (m_htiroot = AddTreeItemForID(TVI_ROOT, cls)) != NULL;
- }
-
- if (result)
- {
- result = mgr->FindClassInstances(cls, &PopulateInstancesCB, this);
- }
-
- return result;
- }
-
-