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

📄 searchtree.cpp

📁 该软件为EDA行业所用
💻 CPP
字号:
// SearchTree.cpp : implementation file
//

#include "stdafx.h"
#include "LIB2DXD.h"
#include "SearchTree.h"
#include "FolderTreeCtrl.h"

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

CStringList m_searchResult;
CString searchPath;
/////////////////////////////////////////////////////////////////////////////
// CSearchTree dialog


CSearchTree::CSearchTree(CWnd* pParent /*=NULL*/)
	: CDialog(CSearchTree::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSearchTree)
	m_fileName = _T("");
	//}}AFX_DATA_INIT
}


void CSearchTree::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSearchTree)
	DDX_Control(pDX, IDC_SEARCHTREE, m_searchTree);
	DDX_Text(pDX, IDC_EDIT1, m_fileName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSearchTree, CDialog)
	//{{AFX_MSG_MAP(CSearchTree)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSearchTree message handlers

BOOL CSearchTree::OnInitDialog() 
{
	CDialog::OnInitDialog();
	// TODO: Add extra initialization here
	m_imgState.Create(IDB_BITMAP_STATE,13, 1, RGB(255,255,255));
	m_imgList.Create(IDB_BITMAP_LIST,16, 1, RGB(255,255,255));
	
	m_searchTree.SetImageList(&m_imgList,TVSIL_NORMAL);
	m_searchTree.SetImageList(&m_imgState,TVSIL_STATE);
	m_searchTree.DisplayTree(NULL,FALSE);
	m_fileName="*.lia";
	UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSearchTree::OnOK() 
{
	// TODO: Add extra validation here
	CStringList *selectedPath;
	CString fileName,tmpResult;
	selectedPath=m_searchTree.GetSelectPath();
	if(!selectedPath)
		return;
	UpdateData(true);
	if(!(*selectedPath).IsEmpty()&&(m_fileName!=""))	{
		int numList=(*selectedPath).GetCount();
		POSITION position=(*selectedPath).GetHeadPosition();
		for(int i=0;i<numList;i++)
		{
			fileName=(*selectedPath).GetNext(position);
			searchPath=fileName;				//return selected path;
			fileName+="\\";
			fileName+=m_fileName;
			SearchFile(fileName);
		}
		CDialog::OnOK();
	}
}
 
void CSearchTree::SearchFile(CString fileName)
{
	CString tmpFileName=fileName;
	CString fileTitle=fileName.Right(fileName.GetLength()-fileName.ReverseFind('\\'));
	CFileFind finder;
	BOOL bFind=finder.FindFile(fileName);
	while(bFind)
	{
		bFind=finder.FindNextFile();
		m_searchResult.AddTail(finder.GetFilePath());
	}


	CWaitCursor wc;
//	SetRedraw( false );
	UINT position=tmpFileName.ReverseFind('\\');//found  folder
	tmpFileName=tmpFileName.Left(position+1);
	CString listFileName=tmpFileName;
	tmpFileName+="*.*";
	bFind=finder.FindFile(tmpFileName);
	while(bFind)							//found a file or folder
	{
		bFind = finder.FindNextFile();
		if ( finder.IsDirectory() && !finder.IsDots() )
		{		
			fileName=finder.GetFilePath();
			fileName+=fileTitle;
			SearchFile(fileName);
		}
		
	}

/*	CFile listFileP;
	listFileName+="\\list of  ";
	listFileName+=fileTitle.Right(fileTitle.GetLength()-3);
	listFileName+="  .lst";
	listFileP.Open(listFileName,CFile::modeCreate | CFile::modeWrite);
	POSITION head=m_searchResult.GetHeadPosition();
	for(int nLoop=0;nLoop<m_searchResult.GetCount();nLoop++)
	{
		CString writeBuffer=m_searchResult.GetNext(head);
		writeBuffer+="\x0d\x0a";
		listFileP.Write(writeBuffer,writeBuffer.GetLength());
	}
	listFileP.Close();*/
}
CStringList* CSearchTree::GetSearchResult(void)
{
	return &m_searchResult;
}

CString CSearchTree::GetSearchPath(void)
{
	return searchPath;
}

⌨️ 快捷键说明

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