📄 ptreeview.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 + -