如何用mfc图形界面画二叉树?

怎么用mfc图形界面画二叉树??
1      
        /   \      
                2       3    
             /   \              
            4    5      
=================
如上图所示,怎么把它画出来啊
只要能简单一点显示出来就可以了~~
大家有没有做过的,给点提示啊?

------解决方案--------------------
其实Treeview本身就是一个树,你可创建一个最多有两个结点的树,然后让Treeview转90度,搞定!
------解决方案--------------------
能让Treeview转90度?
------解决方案--------------------
新建一个MFC单文档应用程序,往其中添加一个文件SortTree.c,文件的内容在后面给出,修改视图类的OnDraw()函数为:
void DrawTree(HWND hwnd,BOOL reGenData);
void CDrawTreeView::OnDraw(CDC* pDC)
{
CDrawTreeDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
DrawTree(this-> m_hWnd,TRUE);
}
就可以了。自己试着好玩的,效果不是特别好。


#include "StdAfx.h "
#include <stdlib.h>
#include <math.h>

typedef struct _node
{
int value;
int visited;
struct _node *left;
struct _node *right;
POINT pos;
}TREE_NODE;
static int g_nItems = 0;
static int g_nTop = 0;
static TREE_NODE **g_pStack = 0;
static TREE_NODE *g_pTree = 0;
static HANDLE g_hNode = 0;
static HANDLE g_hSt = 0;

const int RADIUS = 10;
const int LEVEL_HEIGHT = 50;
const int START_ANGLE = 80;
const int DELTA_ANGLE = 10;
const double PI = 3.1415926;

/* 初始化 */
static void InitState()
{
if (0 != g_hNode) HeapDestroy(g_hNode);
if (0 != g_hSt) HeapDestroy(g_hSt);
g_hNode = HeapCreate(0,sizeof(TREE_NODE)*1000,0);
g_hSt = HeapCreate(0,sizeof(TREE_NODE)*1000,0);
g_pStack= (TREE_NODE**)HeapAlloc(g_hSt,HEAP_ZERO_MEMORY,sizeof(TREE_NODE)*1000);
g_nItems = 0;
g_nTop = 0;
g_pTree = 0;
}

/* 向二叉树中插入一个数 */
static void InsertNumber(int value)
{
TREE_NODE* item;
TREE_NODE* cur;

item = (TREE_NODE*)HeapAlloc(g_hNode,HEAP_ZERO_MEMORY,sizeof(TREE_NODE));
if (0 == item) return;
item-> value = value;

g_nItems += 1;
if (0 == g_pTree)
{
g_pTree = item;
return ;
}
cur = g_pTree;
while (cur)
{
if (value <= cur-> value)
{
if (0 == cur-> left)
{
cur-> left = item;
break;
}
else cur = cur-> left;
}
else
{
if (0 == cur-> right)
{
cur-> right = item;
break;
}
else
cur = cur-> right;
}
}
}

static void GoLeft(HDC hdc,POINT *pt,int *angle)
{
int dist;

MoveToEx(hdc,pt-> x,pt-> y,NULL);
dist = (int)(LEVEL_HEIGHT * tan((*angle) * PI / 180.0));
pt-> x -= dist;
pt-> y += LEVEL_HEIGHT;
LineTo(hdc,pt-> x,pt-> y);

*angle -= DELTA_ANGLE;
}

static void GoRight(HDC hdc,POINT *pt,int *angle)
{
int dist;

MoveToEx(hdc,pt-> x,pt-> y,NULL);
dist = (int)(LEVEL_HEIGHT * tan((*angle) * PI / 180.0));