📄 textview.cpp
字号:
// TextView.cpp : implementation file
//
#include "stdafx.h"
#include "gstools.h"
#include "TextView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// TextView
IMPLEMENT_DYNCREATE(TextView, CEditView)
TextView::TextView()
{
m_file = "";
}
TextView::~TextView()
{
// if(!m_file.IsEmpty() )
// {
// if(!SaveToFile((LPCSTR)m_file))
// {}
// }
}
BEGIN_MESSAGE_MAP(TextView, CEditView)
//{{AFX_MSG_MAP(TextView)
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// TextView drawing
void TextView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// TextView diagnostics
#ifdef _DEBUG
void TextView::AssertValid() const
{
CEditView::AssertValid();
}
void TextView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// TextView message handlers
void TextView::OnChange()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CEditView::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
BOOL TextView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
// cs.style &= ~WS_HSCROLL;
// cs.style &= ~WS_VSCROLL;
return CEditView::PreCreateWindow(cs);
}
BOOL TextView::Init()
{
// GetEditCtrl().ModifyStyle(WS_HSCROLL|WS_VSCROLL, 0);
return TRUE;
}
void TextView::OnShowWindow(BOOL bShow, UINT nStatus)
{
CEditView::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
// if(!g_source.IsReady())
// return;
if(bShow)
{
GSFILE_INFO* pfbuf = g_source.FindSource(g_pWizard->GetCurrentItemPath());
if(pfbuf==NULL)
{
SetWorkFile(g_pWizard->GetCurrentItemPath());
}
else
{
SetWorkFile(pfbuf->strFile);
}
}
else
{
SetWorkFile("");
}
}
BOOL TextView::SetWorkFile(LPCSTR strFile)
{
if(strFile==NULL || m_file==strFile)
return TRUE;
if(!m_file.IsEmpty() )
{
if(!SaveToFile((LPCSTR)m_file))
return FALSE;
}
m_file = strFile;
if(!m_file.IsEmpty())
{
if(!LoadFile(strFile))
return FALSE;
}
else
{
}
return TRUE;
}
BOOL TextView::SaveToFile(LPCSTR strFile)
{
CFile f;
if( !f.Open( strFile, CFile::modeCreate | CFile::modeWrite ) )
{
return FALSE;
}
CArchive ar( &f, CArchive::store);
SerializeRaw(ar);
return TRUE;
}
BOOL TextView::LoadFile(LPCSTR strFile)
{
CFile f;
if( !f.Open( strFile, CFile::modeRead ) )
{
return FALSE;
}
CArchive ar( &f, CArchive::load);
SerializeRaw(ar);
return TRUE;
}
BOOL TextView::Save()
{
if(!m_file.IsEmpty() )
{
return SaveToFile((LPCSTR)m_file);
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -