addtocollectiondlg.cpp

来自「离线的RSS阅读器」· C++ 代码 · 共 102 行

CPP
102
字号
// AddToCollectionDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DiamondReader.h"
#include "AddToCollectionDlg.h"
#include "helper.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAddToCollectionDlg dialog


CAddToCollectionDlg::CAddToCollectionDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAddToCollectionDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAddToCollectionDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CAddToCollectionDlg::CAddToCollectionDlg(DirNode *root,DirNode **select,CWnd* pParent )
	: CDialog(CAddToCollectionDlg::IDD, pParent)
{
	result = select;
	this->root = root;
	
}

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


BEGIN_MESSAGE_MAP(CAddToCollectionDlg, CDialog)
	//{{AFX_MSG_MAP(CAddToCollectionDlg)
	ON_BN_CLICKED(IDC_CANCLE, OnCancle)
	ON_BN_CLICKED(IDC_OK, OnOk)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddToCollectionDlg message handlers

void CAddToCollectionDlg::OnCancle() 
{
	// TODO: Add your control notification handler code here
	EndDialog(1);
	
	
}

void CAddToCollectionDlg::OnOk() 
{
	// TODO: Add your control notification handler code here
	HTREEITEM h = m_tree.GetSelectedItem();
	if (h)
	{
		*result = (DirNode*)m_tree.GetItemData(h);
		EndDialog(0);
	}
	
}

void CAddToCollectionDlg::makeTree(MyTreeNode *root,HTREEITEM treeRoot){
	if(!root||root->type){
		return;
	}
	DirNode *dir = (DirNode*)root;
	HTREEITEM h = this->m_tree.InsertItem(root->name,treeRoot,TVI_FIRST);
	this->m_tree.SetItemData(h,(DWORD)dir);
	MyTreeNode *firstChild = dir->firstChild;
	while (firstChild)
	{
		makeTree(firstChild,h);
		firstChild = firstChild->nextSubling;
	}
	
}

BOOL CAddToCollectionDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CRect rect;
	GetClientRect(&rect);
	rect.bottom = rect.bottom-30;


	this->makeTree(root);

	return TRUE; 
}

⌨️ 快捷键说明

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