📄 extntreectrl.cpp
字号:
// ExtnTreeCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "FileTransClt.h"
#include "ExtnTreeCtrl.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtnTreeCtrl
CExtnTreeCtrl::CExtnTreeCtrl()
{
}
CExtnTreeCtrl::~CExtnTreeCtrl()
{
}
BEGIN_MESSAGE_MAP(CExtnTreeCtrl, CTreeCtrl)
ON_WM_CONTEXTMENU()
//{{AFX_MSG_MAP(CExtnTreeCtrl)
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtnTreeCtrl message handlers
CString CExtnTreeCtrl::GetFullPath(HTREEITEM hItem)
{
// get the Full Path of the item
CString strReturn;
CString strTemp;
HTREEITEM hParent = hItem;
strReturn = "";
while ( hParent )
{
strTemp = GetItemText( hParent );
strTemp += "\\";
strReturn = strTemp + strReturn;
hParent = GetParentItem( hParent );
}
strReturn.TrimRight( '\\' );
return strReturn;
}
void CExtnTreeCtrl::OnContextMenu(CWnd*, CPoint point)
{
// CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1){ //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_EXTN_TREE_CTRL)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);
}
}
void CExtnTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTreeCtrl::OnRButtonDown(nFlags, point);
}
CString CExtnTreeCtrl::GetSubPath(CString fullPath)
{
//
// getting the last SubPath from a PathString
// e.g. C:\temp\readme.txt
// the result = readme.txt
static CString strTemp;
int iPos;
strTemp = fullPath;
if ( strTemp.Right(1) == '\\' )
strTemp.SetAt( strTemp.GetLength() - 1, '\0' );
iPos = strTemp.ReverseFind( '\\' );
if ( iPos != -1 )
strTemp = strTemp.Mid( iPos + 1);
return strTemp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -