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

📄 fileviewform.cpp

📁 Visual C++编写的工程解析器源代码
💻 CPP
字号:
// FileViewForm.cpp : implementation file
//

#include "stdafx.h"
#include "MainFrm.h"
#include "ParseCProj.h"
#include "FileViewForm.h"
#include "RichEditCtrlEx.h"
#include "ParseCProjView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFileViewForm dialog
IMPLEMENT_DYNCREATE(CFileViewForm, CDialog)

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


void CFileViewForm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFileViewForm)
	DDX_Control(pDX, IDC_FILEVIEW_TREE, m_wndFileTree);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFileViewForm, CDialog)
	//{{AFX_MSG_MAP(CFileViewForm)
	ON_WM_SIZE()
	ON_NOTIFY(TVN_SELCHANGED, IDC_FILEVIEW_TREE, OnFileTreeSelChanged)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFileViewForm message handlers

void CFileViewForm::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	if(m_wndFileTree.GetSafeHwnd())
	{
		CRect rect;
		this->GetClientRect(rect);
		m_wndFileTree.SetWindowPos(NULL, rect.left, rect.top,
			rect.Width(), rect.Height(), SWP_SHOWWINDOW);
	}
}

void CFileViewForm::OnFileTreeSelChanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
	//构造文件路径
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	TV_ITEM tci = pNMTreeView->itemNew;
	CString strFilename = m_wndFileTree.GetItemText(tci.hItem);

	HTREEITEM hParentItem = m_wndFileTree.GetParentItem(tci.hItem);
	hParentItem = m_wndFileTree.GetParentItem(hParentItem);
	
	if(hParentItem)
	{
		CString strBasePath = m_wndFileTree.GetItemText(hParentItem);
		int nIndex = strBasePath.ReverseFind('\\');
		strBasePath = strBasePath.Left(nIndex + 1);
		
		strFilename = strBasePath + strFilename;
		//
		CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
		HWND hWnd = pMainFrame->m_wndContentTab.GetPageWnd(0);
		CRichEditCtrlEx* pRichEdit = (CRichEditCtrlEx*)CRichEditCtrlEx::FromHandle(hWnd);
		pRichEdit->LoadFromFile(strFilename);

		//改变状态栏信息
		CString strTipInfo = "";
		CString strTmp = (CString)strFilename;
		strTmp = strTmp.Right(strTmp.GetLength() - strTmp.ReverseFind('\\') - 1);
		
		strTipInfo.Format("[文件名]%s  [大小]:%d字节", strTmp, pRichEdit->GetTextLength());
		pMainFrame->m_wndStatusBar.SetPaneText(2, strTipInfo);
	}
	//
	*pResult = 0;
}

⌨️ 快捷键说明

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