⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ptreeview.cpp

📁 中科院开源的ictprop源码,使用方法: 1、修改源码中的InputComboBox.cpp文件 InvokeAction里面的txt文件路径换成你的本地路径; 2、入口在帮助里面
💻 CPP
字号:
// PtreeView.cpp : implementation file
//

#include "stdafx.h"
#include "prop.h"
#include "PtreeView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
char  *buff, *oldbuff;

extern char *cuttoken(char **lhd);
extern char *uncuttoken(char **lhd, char *token);
/////////////////////////////////////////////////////////////////////////////
// CPtreeView

IMPLEMENT_DYNCREATE(CPtreeView, CTreeView)

CPtreeView::CPtreeView()
{
}

CPtreeView::~CPtreeView()
{
}


BEGIN_MESSAGE_MAP(CPtreeView, CTreeView)
	//{{AFX_MSG_MAP(CPtreeView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPtreeView drawing

void CPtreeView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CPtreeView diagnostics

#ifdef _DEBUG
void CPtreeView::AssertValid() const
{
	CTreeView::AssertValid();
}

void CPtreeView::Dump(CDumpContext& dc) const
{
	CTreeView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CPtreeView message handlers

void CPtreeView::OnInitialUpdate() 
{
	CTreeView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	pCtrl = &GetTreeCtrl();
	ASSERT(pCtrl != NULL);

	long        lStyleOld, lStyleMask;

	lStyleMask=TVS_HASLINES|TVS_HASBUTTONS;
	lStyleOld = GetWindowLong(pCtrl->m_hWnd, GWL_STYLE);
	lStyleOld &= ~lStyleMask;
	lStyleOld |= lStyleMask;

	SetWindowLong(m_hWnd, GWL_STYLE, lStyleOld);
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);



	buff=(char *)malloc(5000);
	
}

void CPtreeView::countrules(HTREEITEM hLHS)
{
	char *token, *head;
	HTREEITEM hmyLHS;

	head=cuttoken(&buff);

	hmyLHS=pCtrl->InsertItem(head, hLHS, TVI_LAST);

	token=cuttoken(&buff);
	if (strcmp(token, "(")==0){
		while (*(token=cuttoken(&buff))!='\0'){
			if (strcmp(token, ")")==0)
				return;
			else{
				uncuttoken(&buff, token);
				countrules(hmyLHS);
			}

		}
	}
	else 
	if (*token!='\0'){
		uncuttoken(&buff, token);
		return;
	}

}

void CPtreeView::UpdateTree(int id, CString str)
{
	char s[10], title[20];
	HTREEITEM hLHS;
	// Insert a root item using the structure. We must
	// initialize a TVINSERTSTRUCT structure and pass its
	// address to the call. 

	strcpy(title, "SENTENCE-");

	TVINSERTSTRUCT tvInsert;
	tvInsert.hParent = NULL;
	tvInsert.hInsertAfter = NULL;
	tvInsert.item.mask = TVIF_TEXT;
	tvInsert.item.pszText=strcat(title,  _itoa(id, s, 10));
	strcpy(buff, str.GetBuffer(1));

	hLHS = pCtrl->InsertItem(&tvInsert);

	oldbuff=buff;
	countrules(hLHS);
	buff=oldbuff;

	UpdateWindow();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -