Код, видимо на си плюс плюс
// diff3dViewerView.cpp : Implementierung der Klasse CDiff3dViewerView
//
#include "stdafx.h"
#include "diff3dViewer.h"
#include "diff3dViewerDoc.h"
#include "diff3dViewerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView
IMPLEMENT_DYNCREATE(CDiff3dViewerView, CTreeView)
BEGIN_MESSAGE_MAP(CDiff3dViewerView, CTreeView)
//{{AFX_MSG_MAP(CDiff3dViewerView)
// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingefьgt und entfernt.
// Innerhalb dieser generierten Quelltextabschnitte NICHTS VERДNDERN!
//}}AFX_MSG_MAP
// Standard-Druckbefehle
ON_COMMAND(ID_FILE_PRINT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CTreeView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView Konstruktion/Destruktion
CDiff3dViewerView::CDiff3dViewerView()
{
_ImageList.DeleteImageList();
_ImageList.Attach(HIMAGELIST(ImageList_Create(16,16,ILC_COLOR24,6,50)));
HBITMAP hBitmap;
hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDB_DIFF3DVIEWER_TREE),
IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
CBitmap bitmap;
bitmap.Attach(hBitmap);
_ImageList.Add(&bitmap, &bitmap);
}
CDiff3dViewerView::~CDiff3dViewerView()
{
}
BOOL CDiff3dViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// ZU ERLEDIGEN: Дndern Sie hier die Fensterklasse oder das Erscheinungsbild, indem Sie
// CREATESTRUCT cs modifizieren.
return CTreeView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView Zeichnen
void CDiff3dViewerView::OnDraw(CDC* pDC)
{
CDiff3dViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// ZU ERLEDIGEN: Hier Code zum Zeichnen der ursprьnglichen Daten hinzufьgen
}
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView Drucken
BOOL CDiff3dViewerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// Standardvorbereitung
return DoPreparePrinting(pInfo);
}
void CDiff3dViewerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// ZU ERLEDIGEN: Zusдtzliche Initialisierung vor dem Drucken hier einfьgen
}
void CDiff3dViewerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// ZU ERLEDIGEN: Hier Bereinigungsarbeiten nach dem Drucken einfьgen
}
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView Diagnose
#ifdef _DEBUG
void CDiff3dViewerView::AssertValid() const
{
CTreeView::AssertValid();
}
void CDiff3dViewerView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CDiff3dViewerDoc* CDiff3dViewerView::GetDocument() // Die endgьltige (nicht zur Fehlersuche kompilierte) Version ist Inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDiff3dViewerDoc)));
return (CDiff3dViewerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDiff3dViewerView Nachrichten-Handler
void CDiff3dViewerView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTreeCtrl& tree = this->GetTreeCtrl();
tree.DeleteAllItems();
_hItemMaterials = tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
"MATERIALS",
7, 7, 0, 0, 0, TVI_ROOT, TVI_LAST);
_hItemObjects = tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
"OBJECTS",
7, 7, 0, 0, 0, TVI_ROOT, TVI_LAST);
if (GetDocument()->_pNode != NULL) {
FillObjects(GetDocument()->_pNode, _hItemObjects);
}
for(int i = 0; i < GetDocument()->_Materials.size(); i++) {
CDiff3DLoader::tMaterialMaps& maps = GetDocument()->_Materials[i];
HTREEITEM hItemMaterial = tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
"Material",
5, 5, 0, 0, 0, _hItemMaterials, TVI_LAST);
for(int j = 0; j < maps.size(); j++) {
HTREEITEM hItemMap = tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
"Map",
6, 6, 0, 0, 0, hItemMaterial, TVI_LAST);
tstring strMap;
CDiff3DLoader::tMaterialMap& map = maps[j];
strMap = "Effect: ";
if (map.diff3DMaterialMap.dwEffect == 0) {
strMap += "Solid ";
}
if ((map.diff3DMaterialMap.dwEffect&DIFF3D_MAPEFFECT_ALPHA)
== DIFF3D_MAPEFFECT_ALPHA) {
strMap += "Alpha ";
}
if ((map.diff3DMaterialMap.dwEffect&DIFF3D_MAPEFFECT_ALPHAADD)
== DIFF3D_MAPEFFECT_ALPHAADD) {
strMap += "Additive ";
}
tree.InsertItem(TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
strMap.c_str(),
6, 6, 0, 0, 0, hItemMap, TVI_LAST);
strMap = "Texture: ";
strMap += map.strTexture;
tree.InsertItem(TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
strMap.c_str(),
6, 6, 0, 0, 0, hItemMap, TVI_LAST);
}
}
tree.Expand(_hItemMaterials, TVE_EXPAND);
tree.Expand(_hItemObjects, TVE_EXPAND);
}
void CDiff3dViewerView::OnInitialUpdate()
{
CTreeCtrl& tree = this->GetTreeCtrl();
SetWindowLong(tree,GWL_STYLE,
GetWindowLong(tree,GWL_STYLE)|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS);
tree.SetImageList(&_ImageList,TVSIL_NORMAL);
CTreeView::OnInitialUpdate();
}
void CDiff3dViewerView::FillObjects(CDXA3DObject* pNode, HTREEITEM hParentItem)
{
HTREEITEM hItem;
CTreeCtrl& tree = this->GetTreeCtrl();
{
tstring strObject;
int iImage = 0;
HTREEITEM hInsert = TVI_LAST;
switch (pNode->GetObjectType()) {
case DXA3DOBJ_OBJECT: {
strObject = "object: ";
if (pNode->GetName() != NULL) {
strObject += pNode->GetName();
}
}break;
case DXA3DOBJ_NODE: {
tstring strName;
strObject = "node: ";
if (pNode->GetName() != NULL) {
strName = pNode->GetName();
strObject += strName;
}
iImage = 1;
if (strName.length() >= 3) {
if ((strName[0] == 'd') &&
(strName[1] == 'm') &&
(strName[2] == 'y')) {
iImage = 4;
}
}
}break;
case DXA3DOBJ_MESH: {
strObject = "mesh: ";
if (pNode->GetName() != NULL) {
strObject += pNode->GetName();
}
iImage = 2;
hInsert = TVI_FIRST;
}break;
}
hItem = tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
strObject.c_str(),
iImage, iImage, 0, 0, (DWORD)pNode, hParentItem, hInsert);
}
for (int i = 0; i < pNode->GetChildCount(); i++) {
FillObjects(pNode->GetChild(i), hItem);
}
{
tstring strAnimation; TCHAR chars[10];
strAnimation = "Animation: ";
if (pNode->GetAnimationTimeHierarchy() > 0) {
strAnimation += "Hierarchy: ";
sprintf(chars, "%d ", pNode->GetAnimationTimeHierarchy());
strAnimation += chars;
}
if (pNode->GetAnimationTime() > 0) {
strAnimation += "Object: ";
sprintf(chars, "%d ", pNode->GetAnimationTime());
strAnimation += chars;
}
if ((pNode->GetAnimationTime() > 0) || (pNode->GetAnimationTimeHierarchy() > 0)) {
tree.InsertItem(
TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE,
strAnimation.c_str(),
3, 3, 0, 0, 0, hItem, TVI_FIRST);
}
}
tree.Expand(hItem, TVE_EXPAND);
}