eventlog.cpp
来自「IO函数调用测试」· C++ 代码 · 共 182 行
CPP
182 行
// EventLog.cpp : implementation file
//
#include "stdafx.h"
#include <afxtempl.h>
#include "help.h"
#include "format.h"
#include "IOExplorer.h"
#include "Note.h"
#include "TraceEvent.h"
#include "EventList.h"
#include "EventLog.h"
#include "Annotation.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEventLog property page
IMPLEMENT_DYNCREATE(CEventLog, CPropertyPage)
CEventLog::CEventLog() : CPropertyPage(CEventLog::IDD)
{
//{{AFX_DATA_INIT(CEventLog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CEventLog::~CEventLog()
{
}
void CEventLog::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEventLog)
DDX_Control(pDX, IDC_UP, c_Up);
DDX_Control(pDX, IDC_SAVE_AS, c_SaveAs);
DDX_Control(pDX, IDC_SAVE, c_Save);
DDX_Control(pDX, IDC_OPEN, c_Open);
DDX_Control(pDX, IDC_EXECUTE, c_Execute);
DDX_Control(pDX, IDC_EVENTS, c_Events);
DDX_Control(pDX, IDC_DOWN, c_Down);
DDX_Control(pDX, IDC_DELETE, c_Delete);
DDX_Control(pDX, IDC_CLEAR, c_Clear);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEventLog, CPropertyPage)
//{{AFX_MSG_MAP(CEventLog)
ON_BN_CLICKED(IDC_CLEAR, OnClear)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_DOWN, OnDown)
ON_LBN_DBLCLK(IDC_EVENTS, OnDblclkEvents)
ON_BN_CLICKED(IDC_EXECUTE, OnExecute)
ON_BN_CLICKED(IDC_OPEN, OnOpen)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_UP, OnUp)
ON_BN_CLICKED(IDC_SAVE_AS, OnSaveAs)
ON_BN_CLICKED(IDC_ANNOTATION, OnAnnotation)
ON_LBN_SELCHANGE(IDC_EVENTS, OnSelchangeEvents)
ON_BN_CLICKED(IDC_HELPBUTTON, OnHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEventLog message handlers
void CEventLog::OnClear()
{
switch(AfxMessageBox(IDS_CLEAR_QUESTION, MB_YESNO | MB_ICONQUESTION))
{ /* AfxMessageBox */
case IDYES:
c_Events.ResetContent();
break;
case IDNO:
break;
} /* AfxMessageBox */
updateControls();
}
/****************************************************************************
* CEventLog::OnDelete
* Result: void
*
* Effect:
* Deletes the selected line(s) from the event log
****************************************************************************/
void CEventLog::OnDelete()
{
int count = c_Events.GetSelCount();
if(count == 0)
return; // should never happen
switch(AfxMessageBox(IDS_QUERY_DELETE, MB_YESNO | MB_ICONQUESTION))
{ /* AfxMessageBox */
case IDNO:
return;
case IDYES:
break;
} /* AfxMessageBox */
int * sels = new int[count];
while(c_Events.GetSelCount() > 0)
{ /* delete each */
c_Events.GetSelItems(count, sels);
c_Events.DeleteString(sels[0]);
} /* delete each */
delete [] sels;
updateControls();
}
/****************************************************************************
* CEventLog::OnDown
* Result: void
*
* Effect:
* In the notion of this being a script, moves the current selection(s)
* down by one unit
****************************************************************************/
void CEventLog::OnDown()
{
int count = c_Events.GetSelCount();
if(count != 1)
return; // shouldn't be here
int n;
c_Events.GetSelItems(1, &n);
/*
+-------------------------------------+
| AAA | 0
+-------------------------------------+
| BBB | <= n == 1
+-------------------------------------+
| CCC | 2
+-------------------------------------+
*/
TraceEvent * e = (TraceEvent *)c_Events.GetItemDataPtr(n);
TraceEvent * enew = e->copy();
c_Events.DeleteString(n);
/*
+-------------------------------------+
| AAA | 0
+-------------------------------------+
| CCC | 1
+-------------------------------------+
*/
c_Events.InsertString(n + 1, enew);
c_Events.SetSel(n + 1);
/*
+-------------------------------------+
| AAA | 0
+-------------------------------------+
| CCC | 1
+-------------------------------------+
| BBB | <= n + 1 == 2
+-------------------------------------+
*/
updateControls();
}
/****************************************************************************
* CEventLog::OnDblclkEvents
* Result: void
*
* Effect:
*
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?