📄 outputview.cpp
字号:
// OutputView.cpp : implementation file
//
#include "stdafx.h"
#include "resourceeditor.h"
#include "OutputView.h"
#include "ResDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputView
IMPLEMENT_DYNCREATE(COutputView, CListView)
COutputView::COutputView()
{
m_nCurItem = -1;
}
COutputView::~COutputView()
{
}
BEGIN_MESSAGE_MAP(COutputView, CListView)
//{{AFX_MSG_MAP(COutputView)
ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
ON_COMMAND(IDM_OUT_CLEAR, OnOutClear)
ON_COMMAND(IDM_OUT_GOTO, OnOutGoto)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputView drawing
void COutputView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// COutputView diagnostics
#ifdef _DEBUG
void COutputView::AssertValid() const
{
CListView::AssertValid();
}
void COutputView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COutputView message handlers
void COutputView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
LPNMITEMACTIVATE pnia = (LPNMITEMACTIVATE)pNMHDR;
m_nCurItem = pnia->iItem;
CMenu menu;
VERIFY( menu.LoadMenu(IDM_POPUP_OUT) );
CMenu * pMenu = menu.GetSubMenu(0);
CListCtrl &lst = GetListCtrl();
if( lst.GetItemCount() == 0 )
{
pMenu->EnableMenuItem( IDM_OUT_CLEAR, MF_BYCOMMAND | MF_GRAYED );
}
if( m_nCurItem == -1 )
{
pMenu->EnableMenuItem( IDM_OUT_GOTO, MF_BYCOMMAND | MF_GRAYED );
}
POINT pt = pnia->ptAction;
ClientToScreen(&pt);
pMenu->TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
*pResult = 0;
}
void COutputView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
LPNMITEMACTIVATE pnia = (LPNMITEMACTIVATE)pNMHDR;
m_nCurItem = pnia->iItem;
OnOutGoto();
*pResult = 0;
}
void COutputView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
if( pSender != this )
{
CListCtrl &lst = GetListCtrl();
POUT_BAR_PARAM pobp = (POUT_BAR_PARAM)pHint;
static const int nClmnWidth = 300;
switch( lHint )
{
case WM_OUTBAR_INSERT_CLMN:
{
_ASSERTE( pobp != NULL );
lst.DeleteAllItems();
CHeaderCtrl * pHdrCtrl = lst.GetHeaderCtrl();
int nCount = pHdrCtrl->GetItemCount();
for( int i = nCount - 1; i >= 0; --i )
{
lst.DeleteColumn(i);
}
nCount = pobp->arrTxt.GetSize();
for( i = 0; i < nCount; ++i )
{
lst.InsertColumn(i, pobp->arrTxt[i], LVCFMT_LEFT, nClmnWidth / nCount);
}
}
break;
case WM_OUTBAR_CLEAR:
OnOutClear();
break;
case WM_OUTBAR_ADD_ITEM:
{
_ASSERTE( pobp != NULL );
pobp = (POUT_BAR_PARAM)pHint;
int nItem = lst.GetItemCount();
int nCount = pobp->arrTxt.GetSize();
lst.InsertItem(nItem, pobp->arrTxt[0]);
for( int i = 1; i < nCount; ++i )
{
lst.SetItemText(nItem, i, pobp->arrTxt[i]);
}
lst.SetItemData(nItem, pobp->dwData);
}
default:
break;
}
}
}
BOOL COutputView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.style |= LVS_REPORT;
cs.style |= LVS_SHOWSELALWAYS;
return CListView::PreCreateWindow(cs);
}
void COutputView::OnOutClear()
{
// TODO: Add your command handler code here
CListCtrl &lst = GetListCtrl();
m_nCurItem = -1;
lst.DeleteAllItems();
CHeaderCtrl * pHdrCtrl = lst.GetHeaderCtrl();
int nCount = pHdrCtrl->GetItemCount();
for( int i = nCount - 1; i >= 0; --i )
{
lst.DeleteColumn(i);
}
}
void COutputView::OnOutGoto()
{
// TODO: Add your command handler code here
if( m_nCurItem >= 0 )
{
CDocument * pDoc = GetDocument();
_ASSERTE( pDoc != NULL );
CListCtrl &lst = GetListCtrl();
DWORD dwData = lst.GetItemData(m_nCurItem);
pDoc->UpdateAllViews( this, WM_OUTBAR_GOTO, (CObject *)dwData );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -