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

📄 lineview.cpp

📁 这是书上的代码
💻 CPP
字号:
// LineView.cpp : implementation file
//

#include "stdafx.h"
#include "test.h"
#include "LineView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLineView

IMPLEMENT_DYNCREATE(CLineView, CFormView)

CLineView::CLineView()
	: CFormView(CLineView::IDD)
{
	//{{AFX_DATA_INIT(CLineView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CLineView::~CLineView()
{
}

void CLineView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLineView)
	DDX_Control(pDX, IDC_TREE1, m_tree);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLineView, CFormView)
	//{{AFX_MSG_MAP(CLineView)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLineView diagnostics

#ifdef _DEBUG
void CLineView::AssertValid() const
{
	CFormView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CLineView message handlers

void CLineView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	m_tree.DeleteAllItems();
	TV_INSERTSTRUCT tvinsert;
	tvinsert.hParent = NULL;
	tvinsert.item.mask = TVIF_TEXT;	

	tvinsert.item.pszText = "所有线路";
	HTREEITEM hDad1 = m_tree.InsertItem(&tvinsert);

	char buff[100];
	CString str[7]={"线路1","线路2","线路3","线路4","线路5","线路6"};

	for( int i=0; i< 6; i++)
	{
		wsprintf(buff,"%s",str[i]);
		tvinsert.item.pszText = buff;

		tvinsert.hParent = hDad1;
		m_tree.InsertItem(&tvinsert);	
	}

	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();
}

void CLineView::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	::MoveWindow(m_tree.m_hWnd,0,0,cx,cy,TRUE);
}

⌨️ 快捷键说明

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