MainFrm.h
// MainFrm.h : interface of the CMainFrame class
//
/
#if !defined(AFX_MAINFRM_H__4CC3B08B_0CF1_4241_8290_E2B3E04EEBA2__INCLUDED_)
#define AFX_MAINFRM_H__4CC3B08B_0CF1_4241_8290_E2B3E04EEBA2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
protected:
CSplitterWnd m_wndSplitter;
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
bool m_bSplitterCreated;
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__4CC3B08B_0CF1_4241_8290_E2B3E04EEBA2__INCLUDED_)
MainFrm.cpp
// MyBiTree.cpp: implementation of the CMyBiTree class.
//
//
#include "stdafx.h"
#include "BiTree.h"
#include "MyBiTree.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//
// Construction/Destruction
//
const int CMyBiTree::m_LX=50;//x方向结点间距
const int CMyBiTree::m_HY=70;//y方向结点间距
CMyBiTree::CMyBiTree()
{
root = NULL;
}
CMyBiTree::~CMyBiTree()
{
DestroyBiTree(root);
}
void CMyBiTree::DestroyBiTree(BiTree &r) //销毁二叉树
{
if(r != NULL)
{
if(r->lchild)DestroyBiTree(r->lchild);
if(r->rchild)DestroyBiTree(r->rchild);
free(r);
r = NULL;
}
}
bool CMyBiTree::BiTreeIsEmpty() //树空则返回true
{
if(root != NULL)
return false;
return true;
}
BiTree CMyBiTree::Root() //返回树的根
{
return root;
}
void CMyBiTree::PreOrderTraverse(CDC*pDC)
{
int h=Treeheight(root);
int y=h*m_HY+40;
CString s="先序遍历: ";
PreOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::InOrderTraverse(CDC *pDC)
{
int h=Treeheight(root);
int y=h*m_HY+60;
CString s="中序遍历: ";
InOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::PostOrderTraverse(CDC *pDC)
{
int h=Treeheight(root);
int y=h*m_HY+80;
CString s="后序遍历: ";
PostOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::PreOrder(BiTree root,CString &s)
{
if(root)
{
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
PreOrder(root->lchild,s);
PreOrder(root->rchild,s);
}
}
void CMyBiTree::InOrder(BiTree root,CString &s)
{
if(root)
{
InOrder(root->lchild,s);
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
InOrder(root->rchild,s);
}
}
void CMyBiTree::PostOrder(BiTree root,CString&s)
{
if(root)
{
PostOrder(root->lchild,s);
PostOrder(root->rchild,s);
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
}
}
bool CMyBiTree::InsertNode(int e)
{//往树中插入一个节点,失败则返回false
Node *newnode;
Node *currentnode;
Node *parentnode;
newnode=new Node;
newnode->val=e;
newnode->lchild=NULL;
newnode->rchild=NULL;
if(root==NULL)
{
root=newnode;
return true ;
}
else
{
currentnode=root;
while (currentnode!=NULL)
{
parentnode=currentnode;
if(currentnode->val == e)
{
char s[50];
sprintf(s,"结点:%d 已经存在该树中\n请输入新的结点!",e);
AfxMessageBox(s);
return false;
}
if(currentnode->val > e)
currentnode=currentnode->lchild;
else
currentnode=currentnode->rchild;
}
if(parentnode->val > e)
parentnode->lchild=newnode;
else
parentnode->rchild=newnode;
}
return true;
}
void CMyBiTree::SetPosition()
{
if(root==NULL)return;
int height=Treeheight(root);
if(height==1)
{
root->point.x=100;
root->point.y=m_HY;
return;
}
int lh;
BiTree pLnode;
for(lh=0,pLnode=root;pLnode;pLnode=pLnode->lchild,lh++);
int x=40, n;
n=(int)pow(2,height-1);
int lx=n*m_LX/2;
for(int i=1;i<lh;i++)
{
n/=2;
x+=n*m_LX;
}
root->point.x=x;
root->point.y=m_HY;
SetPosition(root,lx);
}
void CMyBiTree::SetPosition(BiTree root,int L)
{
if(root->lchild!=NULL)
{
root->lchild->point.x=root->point.x-L;
root->lchild->point.y=root->point.y+m_HY;
SetPosition(root->lchild,L/2);
}
if(root->rchild!=NULL)
{
root->rchild->point.x=root->point.x+L;
root->rchild->point.y=root->point.y+m_HY;
SetPosition(root->rchild,L/2);
}
}
int CMyBiTree::Treeheight(BiTree root)
{
if(root != NULL)
{
int lh=Treeheight(root->lchild);
int rh=Treeheight(root->rchild);
if(lh>=rh)
return lh+1;
else
return rh+1;
}
else
return 0;
}
void CMyBiTree::DrawTree(BiTree root,CDC *pDC)
{
if(root==NULL)return;
POINT point=root->point;
if(root->lchild != NULL)
{
pDC->MoveTo(point);
pDC->LineTo(root->lchild->point);
DrawTree(root->lchild,pDC);
}
if(root->rchild !=NULL)
{
pDC->MoveTo(point);
pDC->LineTo(root->rchild->point);
DrawTree(root->rchild,pDC);
}
int R=20;
pDC->Ellipse(point.x-R,point.y-R,point.x+R,point.y+R);
char ch[10];
sprintf(ch,"%d",root->val);
pDC->TextOut(point.x-7,point.y-7,ch);
}
MyBiTree.h
// MyBiTree.h: interface for the CMyBiTree class.
//
//
#if !defined(AFX_MYBITREE_H__860FE23F_1A15_42F0_9759_8D9A3C8EF4D7__INCLUDED_)
#define AFX_MYBITREE_H__860FE23F_1A15_42F0_9759_8D9A3C8EF4D7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/*
#define LH +1 //左高
#define EH 0 //等高
#define RH -1 //右高
#define EQ(a,b) ((a) == (b))
#define LT(a,b) ((a) < (b))
*/
//#define LQ(a,b) ((a) <= (b))
typedef struct Node
{
// int bf; //平衡因子
int val; //值
Node *lchild;
Node *rchild;
POINT point;//在图中的坐标
}*BiTree;
typedef void(* Visit)(Node*);
class CMyBiTree
{
public:
CMyBiTree();
virtual ~CMyBiTree();
// void ClearBiTree(); //将二叉树清空
bool BiTreeIsEmpty(); //树空则返回true
BiTree Root(); //返回树的根
bool InsertNode(int e); //往树中插入一个节点,失败则返回false
// bool DeleteNode(Node *p); //往树中删除一个节点,失败则返回false
void SetPosition();
void SetPosition(BiTree root,int L);
void DrawTree(BiTree root,CDC *pDC);
int Treeheight(Node *root);
void DestroyBiTree(BiTree &r); //销毁二叉树
void PreOrderTraverse(CDC*pDC);
void InOrderTraverse(CDC *pDC);
void PostOrderTraverse(CDC *pDC);
private:
void PreOrder(BiTree root,CString&s);
void InOrder(BiTree root,CString&s);
void PostOrder(BiTree root,CString&s);
public:
BiTree root;
static const int m_LX,m_HY;
};
#endif // !defined(AFX_MYBITREE_H__860FE23F_1A15_42F0_9759_8D9A3C8EF4D7__INCLUDED_)
MyBiTree.cpp
// MyBiTree.cpp: implementation of the CMyBiTree class.
//
//
#include "stdafx.h"
#include "BiTree.h"
#include "MyBiTree.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//
// Construction/Destruction
//
const int CMyBiTree::m_LX=50;//x方向结点间距
const int CMyBiTree::m_HY=70;//y方向结点间距
CMyBiTree::CMyBiTree()
{
root = NULL;
}
CMyBiTree::~CMyBiTree()
{
DestroyBiTree(root);
}
void CMyBiTree::DestroyBiTree(BiTree &r) //销毁二叉树
{
if(r != NULL)
{
if(r->lchild)DestroyBiTree(r->lchild);
if(r->rchild)DestroyBiTree(r->rchild);
free(r);
r = NULL;
}
}
bool CMyBiTree::BiTreeIsEmpty() //树空则返回true
{
if(root != NULL)
return false;
return true;
}
BiTree CMyBiTree::Root() //返回树的根
{
return root;
}
void CMyBiTree::PreOrderTraverse(CDC*pDC)
{
int h=Treeheight(root);
int y=h*m_HY+40;
CString s="先序遍历: ";
PreOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::InOrderTraverse(CDC *pDC)
{
int h=Treeheight(root);
int y=h*m_HY+60;
CString s="中序遍历: ";
InOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::PostOrderTraverse(CDC *pDC)
{
int h=Treeheight(root);
int y=h*m_HY+80;
CString s="后序遍历: ";
PostOrder(root,s);
pDC->TextOut(20,y,s);
}
void CMyBiTree::PreOrder(BiTree root,CString &s)
{
if(root)
{
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
PreOrder(root->lchild,s);
PreOrder(root->rchild,s);
}
}
void CMyBiTree::InOrder(BiTree root,CString &s)
{
if(root)
{
InOrder(root->lchild,s);
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
InOrder(root->rchild,s);
}
}
void CMyBiTree::PostOrder(BiTree root,CString&s)
{
if(root)
{
PostOrder(root->lchild,s);
PostOrder(root->rchild,s);
CString s1;
s1.Format("%d, ",root->val);
s+=s1;
}
}
bool CMyBiTree::InsertNode(int e)
{//往树中插入一个节点,失败则返回false
Node *newnode;
Node *currentnode;
Node *parentnode;
newnode=new Node;
newnode->val=e;
newnode->lchild=NULL;
newnode->rchild=NULL;
if(root==NULL)
{
root=newnode;
return true ;
}
else
{
currentnode=root;
while (currentnode!=NULL)
{
parentnode=currentnode;
if(currentnode->val == e)
{
char s[50];
sprintf(s,"结点:%d 已经存在该树中\n请输入新的结点!",e);
AfxMessageBox(s);
return false;
}
if(currentnode->val > e)
currentnode=currentnode->lchild;
else
currentnode=currentnode->rchild;
}
if(parentnode->val > e)
parentnode->lchild=newnode;
else
parentnode->rchild=newnode;
}
return true;
}
void CMyBiTree::SetPosition()
{
if(root==NULL)return;
int height=Treeheight(root);
if(height==1)
{
root->point.x=100;
root->point.y=m_HY;
return;
}
int lh;
BiTree pLnode;
for(lh=0,pLnode=root;pLnode;pLnode=pLnode->lchild,lh++);
int x=40, n;
n=(int)pow(2,height-1);
int lx=n*m_LX/2;
for(int i=1;i<lh;i++)
{
n/=2;
x+=n*m_LX;
}
root->point.x=x;
root->point.y=m_HY;
SetPosition(root,lx);
}
void CMyBiTree::SetPosition(BiTree root,int L)
{
if(root->lchild!=NULL)
{
root->lchild->point.x=root->point.x-L;
root->lchild->point.y=root->point.y+m_HY;
SetPosition(root->lchild,L/2);
}
if(root->rchild!=NULL)
{
root->rchild->point.x=root->point.x+L;
root->rchild->point.y=root->point.y+m_HY;
SetPosition(root->rchild,L/2);
}
}
int CMyBiTree::Treeheight(BiTree root)
{
if(root != NULL)
{
int lh=Treeheight(root->lchild);
int rh=Treeheight(root->rchild);
if(lh>=rh)
return lh+1;
else
return rh+1;
}
else
return 0;
}
void CMyBiTree::DrawTree(BiTree root,CDC *pDC)
{
if(root==NULL)return;
POINT point=root->point;
if(root->lchild != NULL)
{
pDC->MoveTo(point);
pDC->LineTo(root->lchild->point);
DrawTree(root->lchild,pDC);
}
if(root->rchild !=NULL)
{
pDC->MoveTo(point);
pDC->LineTo(root->rchild->point);
DrawTree(root->rchild,pDC);
}
int R=20;
pDC->Ellipse(point.x-R,point.y-R,point.x+R,point.y+R);
char ch[10];
sprintf(ch,"%d",root->val);
pDC->TextOut(point.x-7,point.y-7,ch);
}
DlgView.h
#if !defined(AFX_DLGVIEW_H__0D34A291_3783_4FD5_8139_26D707E435A7__INCLUDED_)
#define AFX_DLGVIEW_H__0D34A291_3783_4FD5_8139_26D707E435A7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgView.h : header file
//
/
// CDlgView form view
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
class CDlgView : public CFormView
{
protected:
CDlgView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CDlgView)
// Form Data
public:
//{{AFX_DATA(CDlgView)
enum { IDD = IDD_DIALOG1 };
int m_data;
//}}AFX_DATA
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgView)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CDlgView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CDlgView)
afx_msg void OnInserNode();
afx_msg void OnPre();
afx_msg void OnIn();
afx_msg void OnPost();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGVIEW_H__0D34A291_3783_4FD5_8139_26D707E435A7__INCLUDED_)
DlgView.cpp
// DlgView.cpp : implementation file
//
#include "stdafx.h"
#include "BiTree.h"
#include "DlgView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CDlgView
IMPLEMENT_DYNCREATE(CDlgView, CFormView)
CDlgView::CDlgView()
: CFormView(CDlgView::IDD)
{
//{{AFX_DATA_INIT(CDlgView)
m_data = 0;
//}}AFX_DATA_INIT
}
CDlgView::~CDlgView()
{
}
void CDlgView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgView)
DDX_Text(pDX, IDC_EDIT1, m_data);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgView, CFormView)
//{{AFX_MSG_MAP(CDlgView)
ON_BN_CLICKED(IDC_BUTTON1, OnInserNode)
ON_BN_CLICKED(IDC_PRE, OnPre)
ON_BN_CLICKED(IDC_IN, OnIn)
ON_BN_CLICKED(IDC_POST, OnPost)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CDlgView diagnostics
#ifdef _DEBUG
void CDlgView::AssertValid() const
{
CFormView::AssertValid();
}
void CDlgView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/
// CDlgView message handlers
#include "BiTreeDoc.h"
void CDlgView::OnInserNode()
{
// TODO: Add your control notification handler code here
CBiTreeDoc* pDoc = (CBiTreeDoc*)GetDocument();
ASSERT_VALID(pDoc);
UpdateData();
pDoc->m_tree.InsertNode(m_data);//插入节点
//将焦点移到编辑框
CEdit *ed;
ed = (CEdit*)GetDlgItem(IDC_EDIT1);
ed->SetFocus();
ed->SetSel(0,-1);
pDoc->UpdateAllViews(NULL);
}
void CDlgView::OnPre()
{
// TODO: Add your control notification handler code here
CBiTreeDoc* pDoc = (CBiTreeDoc*)GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_pre=!pDoc->m_pre;
pDoc->UpdateAllViews(NULL);
}
void CDlgView::OnIn()
{
// TODO: Add your control notification handler code here
CBiTreeDoc* pDoc = (CBiTreeDoc*)GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_in=!pDoc->m_in;
pDoc->UpdateAllViews(NULL);
}
void CDlgView::OnPost()
{
// TODO: Add your control notification handler code here
CBiTreeDoc* pDoc = (CBiTreeDoc*)GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_post=!pDoc->m_post;
pDoc->UpdateAllViews(NULL);
}
BiTreeDoc.h
// BiTreeDoc.h : interface of the CBiTreeDoc class
//
/
#if !defined(AFX_BITREEDOC_H__755EB244_976A_4D91_AA79_40663FF33CB8__INCLUDED_)
#define AFX_BITREEDOC_H__755EB244_976A_4D91_AA79_40663FF33CB8__INCLUDED_
#include "MyBiTree.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CBiTreeDoc : public CDocument
{
protected: // create from serialization only
CBiTreeDoc();
DECLARE_DYNCREATE(CBiTreeDoc)
// Attributes
public:
CMyBiTree m_tree; //树
bool m_pre; //先序
bool m_in; //中序
bool m_post;//后序
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBiTreeDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CBiTreeDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CBiTreeDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BITREEDOC_H__755EB244_976A_4D91_AA79_40663FF33CB8__INCLUDED_)
BiTreeDoc.cpp
// BiTreeDoc.cpp : implementation of the CBiTreeDoc class
//
#include "stdafx.h"
#include "BiTree.h"
#include "BiTreeDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CBiTreeDoc
IMPLEMENT_DYNCREATE(CBiTreeDoc, CDocument)
BEGIN_MESSAGE_MAP(CBiTreeDoc, CDocument)
//{{AFX_MSG_MAP(CBiTreeDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CBiTreeDoc construction/destruction
CBiTreeDoc::CBiTreeDoc()
{
// TODO: add one-time construction code here
m_pre=false; //先序
m_in=false; //中序
m_post=false;//后序
}
CBiTreeDoc::~CBiTreeDoc()
{
}
BOOL CBiTreeDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/
// CBiTreeDoc serialization
void CBiTreeDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/
// CBiTreeDoc diagnostics
#ifdef _DEBUG
void CBiTreeDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CBiTreeDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/
// CBiTreeDoc commands
// BiTree.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "BiTree.h"
#include "MainFrm.h"
#include "BiTreeDoc.h"
#include "BiTreeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CBiTreeApp
BEGIN_MESSAGE_MAP(CBiTreeApp, CWinApp)
//{{AFX_MSG_MAP(CBiTreeApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/
// CBiTreeApp construction
CBiTreeApp::CBiTreeApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/
// The one and only CBiTreeApp object
CBiTreeApp theApp;
Node *tempc; //临时存放孩子节点指针,以求得双亲
Node *tempp; //临时存放求得的父节点指针
/
// CBiTreeApp initialization
BOOL CBiTreeApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CBiTreeDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CBiTreeView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
tempp = NULL;//初始化为空
tempc = NULL;//初始化为空
return TRUE;
}
/
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CBiTreeApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/
// CBiTreeApp message handlers
// BiTree.h : main header file for the BITREE application
//
#if !defined(AFX_BITREE_H__07FFDB09_1FEA_4CFA_A1E0_B6ECB18889CB__INCLUDED_)
#define AFX_BITREE_H__07FFDB09_1FEA_4CFA_A1E0_B6ECB18889CB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/
// CBiTreeApp:
// See BiTree.cpp for the implementation of this class
//
class CBiTreeApp : public CWinApp
{
public:
CBiTreeApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBiTreeApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CBiTreeApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BITREE_H__07FFDB09_1FEA_4CFA_A1E0_B6ECB18889CB__INCLUDED_)