PtreeView.cpp
资源名称:ictprop.rar [点击查看]
上传用户:tenhai
上传日期:2021-02-19
资源大小:492k
文件大小:3k
源码类别:
组合框控件
开发平台:
Visual C++
- // 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))!=' '){
- if (strcmp(token, ")")==0)
- return;
- else{
- uncuttoken(&buff, token);
- countrules(hmyLHS);
- }
- }
- }
- else
- if (*token!=' '){
- 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();
- }