📄 classviewform.cpp
字号:
// ClassViewForm.cpp : implementation file
//
#include "stdafx.h"
#include "ParseCProj.h"
#include "ClassViewForm.h"
#include "MainFrm.h"
#include "RichEditCtrlEx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClassViewForm dialog
IMPLEMENT_DYNCREATE(CClassViewForm, CDialog)
CClassViewForm::CClassViewForm(CWnd* pParent /*=NULL*/)
: CDialog(CClassViewForm::IDD, pParent)
{
//{{AFX_DATA_INIT(CClassViewForm)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CClassViewForm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClassViewForm)
DDX_Control(pDX, IDC_CLASSVIEW_TREE, m_wndClassTree);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClassViewForm, CDialog)
//{{AFX_MSG_MAP(CClassViewForm)
ON_WM_SIZE()
ON_NOTIFY(TVN_SELCHANGED, IDC_CLASSVIEW_TREE, OnSelchangedClassviewTree)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClassViewForm message handlers
void CClassViewForm::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(m_wndClassTree.GetSafeHwnd())
{
CRect rect;
this->GetClientRect(rect);
m_wndClassTree.SetWindowPos(NULL, rect.left, rect.top,
rect.Width(), rect.Height(), SWP_SHOWWINDOW);
}
}
void CClassViewForm::OnSelchangedClassviewTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TV_ITEM tci = pNMTreeView->itemNew;
//得到当前被选中的类所对应的文件
char lpFilename [MAX_PATH];
memset(lpFilename, 0x0, sizeof(lpFilename));
HTREEITEM hClassRootItem = m_wndClassTree.GetRootItem();
HTREEITEM hFileNameItem = NULL;
if((DWORD)m_wndClassTree.GetParentItem(tci.hItem) == (DWORD)hClassRootItem)
hFileNameItem = tci.hItem;
else
{
if(!m_wndClassTree.ItemHasChildren(tci.hItem))
hFileNameItem = m_wndClassTree.GetParentItem(tci.hItem);
}
if(hFileNameItem != NULL)
{
strcpy( lpFilename, (char*)m_wndClassTree.GetItemData(hFileNameItem) );
CFileFind* ffFinder = new CFileFind;
if(ffFinder->FindFile((LPCTSTR)lpFilename))
{
//加载文件以显示
CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
HWND hWnd = pMainFrame->m_wndContentTab.GetPageWnd(0);
CRichEditCtrlEx* pRichEdit = (CRichEditCtrlEx*)CRichEditCtrlEx::FromHandle(hWnd);
pRichEdit->LoadFromFile((CString)lpFilename);
//改变状态栏信息
CString strTipInfo = "";
CString strTmp = (CString)lpFilename;
strTmp = strTmp.Right(strTmp.GetLength() - strTmp.ReverseFind('\\') - 1);
strTipInfo.Format("[文件名]%s [大小]:%d字节", strTmp, pRichEdit->GetTextLength());
pMainFrame->m_wndStatusBar.SetPaneText(2, strTipInfo);
}
delete ffFinder;
}
//
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -