foldertree.cpp

来自「实现类似wince系统自带顶部工具条」· C++ 代码 · 共 76 行

CPP
76
字号
// FolderTree.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "FolderTree.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFolderTree

CFolderTree::CFolderTree()
{
}

CFolderTree::~CFolderTree()
{
}


BEGIN_MESSAGE_MAP(CFolderTree, CTreeCtrl)
	//{{AFX_MSG_MAP(CFolderTree)
	ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFolderTree message handlers

void CFolderTree::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) 
{
	HTREEITEM htiSelected = GetSelectedItem();
	const CString strText = GetItemText(htiSelected);

	ASSERT(!strText.IsEmpty());

	CString strMsg;
	strMsg.Format(_T("%s was selected"), strText);

	AfxMessageBox(strMsg);

	PostMessage(WM_HIDETREE, 1, NULL);

	*pResult = 0;
}

LRESULT CFolderTree::OnHideTree(WPARAM wParam, LPARAM lParam)
{
	ShowWindow(SW_HIDE);

	return 0;
}

int CFolderTree::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTreeCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	HTREEITEM hti = InsertItem(_T("ActiveSync"), -1,-1);
	VERIFY(InsertItem(_T("Inbox"), -1,-1, hti) != NULL);
	VERIFY(InsertItem(_T("Outbox"), -1,-1, hti) != NULL);
	VERIFY(InsertItem(_T("Drafts"), -1,-1, hti) != NULL);
	VERIFY(InsertItem(_T("Sent Items"), -1,-1, hti) != NULL);

	VERIFY(SelectItem(hti));
	
	VERIFY(Expand(hti, TVE_EXPAND));
	
	return 0;
}

⌨️ 快捷键说明

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