📄 logview.cpp
字号:
// LogView.cpp : implementation file
//
#include "stdafx.h"
#include "PhysicM.h"
#include "LogView.h"
#define LOG_LIMIT 5000
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogView
IMPLEMENT_DYNCREATE(CLogView, CRichEditView)
CLogView::CLogView()
{
}
CLogView::~CLogView()
{
}
BEGIN_MESSAGE_MAP(CLogView, CRichEditView)
//{{AFX_MSG_MAP(CLogView)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogView drawing
void CLogView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CLogView diagnostics
#ifdef _DEBUG
void CLogView::AssertValid() const
{
CRichEditView::AssertValid();
}
void CLogView::Dump(CDumpContext& dc) const
{
CRichEditView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLogView message handlers
int CLogView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CRichEditView::OnCreate(lpCreateStruct) == -1)
return -1;
pRichEditCtrl=&GetRichEditCtrl();
pRichEditCtrl->SetBackgroundColor(FALSE,RGB(0,0,62));
CFont fnt;
fnt.CreatePointFont(90,"宋体");
pRichEditCtrl->SetFont(&fnt,TRUE);
pRichEditCtrl->SetReadOnly();
// TODO: Add your specialized creation code here
return 0;
}
/*
int CLogView::vAddMsg(bool errmsg,const char *format, va_list vlist)
{
CRichEditCtrl &m_ctlLog=GetRichEditCtrl();
char dtstr[15],tmstr[15];
_strtime(tmstr);
_strdate(dtstr);
char msg[1000];
vsprintf(msg,format,vlist);
// lgprintf(msg);
if(strlen(format)>2)
sprintf(msg,"[%s %s] ",dtstr,tmstr);
int rt=vsprintf(msg+strlen(msg),format,vlist);
strcat(msg,"\r\n");
int len=m_ctlLog.GetTextLength();
if(len>LOG_LIMIT-1000) {
m_ctlLog.SetSel(LOG_LIMIT-1000,len);
m_ctlLog.ReplaceSel("");
}
m_ctlLog.SetSel(len,len);
m_ctlLog.ReplaceSel(msg);
CHARFORMAT cf;
m_ctlLog.SetSel(len,m_ctlLog.GetTextLength()-1);
cf.cbSize=sizeof(CHARFORMAT);
if(errmsg) {
cf.dwMask=CFM_COLOR | CFM_BOLD;
cf.dwEffects=CFE_BOLD;
cf.crTextColor=RGB(255,0,0);
}
else {
cf.dwMask=CFM_COLOR;
cf.dwEffects=0;
cf.crTextColor=RGB(0,255,0);
}
m_ctlLog.SetSelectionCharFormat(cf);
m_ctlLog.SetSel(len,len);
return rt;
}
*/
int CLogView::vAddMsg(bool errmsg,const char *format, va_list vlist)
{
//CRichEditCtrl &m_ctlLog=GetRichEditCtrl();
char dtstr[15],tmstr[15];
_strtime(tmstr);
_strdate(dtstr);
char msg[1000];
vsprintf(msg,format,vlist);
// lgprintf(msg);
if(strlen(format)>2)
sprintf(msg,"[%s %s] ",dtstr,tmstr);
int rt=vsprintf(msg+strlen(msg),format,vlist);
strcat(msg,"\r\n");
int len=GetRichEditCtrl().GetTextLength();
if(len>LOG_LIMIT-1000) {
GetRichEditCtrl().SetSel(LOG_LIMIT-1000,len);
GetRichEditCtrl().ReplaceSel("");
}
GetRichEditCtrl().SetSel(len,len);
GetRichEditCtrl().ReplaceSel(msg);
CHARFORMAT cf;
GetRichEditCtrl().SetSel(len,GetRichEditCtrl().GetTextLength()-1);
cf.cbSize=sizeof(CHARFORMAT);
if(errmsg) {
cf.dwMask=CFM_COLOR | CFM_BOLD;
cf.dwEffects=CFE_BOLD;
cf.crTextColor=RGB(255,0,0);
}
else {
cf.dwMask=CFM_COLOR;
cf.dwEffects=0;
cf.crTextColor=RGB(0,255,0);
}
GetRichEditCtrl().SetSelectionCharFormat(cf);
GetRichEditCtrl().SetSel(len,len);
return rt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -