⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notebookview.cpp

📁 notbook是VS2005下WinCE6.0记事本源码
💻 CPP
字号:
// NoteBookView.cpp : implementation of the CNoteBookView class
//

#include "stdafx.h"
#include "NoteBook.h"
#include "MainFrm.h"
#include "NoteBookDoc.h"
#include "NoteBookView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNoteBookView

IMPLEMENT_DYNCREATE(CNoteBookView, CEditView)

BEGIN_MESSAGE_MAP(CNoteBookView, CEditView)
	//{{AFX_MSG_MAP(CNoteBookView)
	//}}AFX_MSG_MAP
	ON_CBN_SELENDOK(IDC_COMBO1, OnSelendokCombo1)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNoteBookView construction/destruction

CNoteBookView::CNoteBookView()
{
}

CNoteBookView::~CNoteBookView()
{
}

BOOL CNoteBookView::PreCreateWindow(CREATESTRUCT& cs)
{
	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping

	return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CNoteBookView drawing

void CNoteBookView::OnDraw(CDC* pDC)
{
	CNoteBookDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
}

/////////////////////////////////////////////////////////////////////////////
// CNoteBookView diagnostics

#ifdef _DEBUG
void CNoteBookView::AssertValid() const
{
	CEditView::AssertValid();
}

void CNoteBookView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}

CNoteBookDoc* CNoteBookView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNoteBookDoc)));
	return (CNoteBookDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CNoteBookView message handlers

void CNoteBookView::OnInitialUpdate() 
{
	CEditView::OnInitialUpdate();
	////////设置窗口标题
	AfxGetMainWnd()->SetWindowText(L"记事本");
	////////设置初始文件路径变量
	CEdit& theEdit = GetEditCtrl();	
	m_strFilePath = L"";	
	theEdit.SetLimitText(128 * 1024);   ////////设置文本长度, 单位字节
	///////设置组合框大字体
	CComboBox* pComBox = ((CMainFrame*)GetParentFrame())->pComBox;
	LOGFONT  lf;
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 20;
	lstrcpy(lf.lfFaceName, _T("宋体")); 
	//////VERIFY(m_ComboFont.CreateFontIndirect(&lf));
	if(! m_ComboFont.CreateFontIndirect(&lf))
	{
		MessageBox(L"cannot create 宋体");
		return;
	}
	pComBox->SetFont(&m_ComboFont);
	pComBox->AddString(L"默认字");///   
	pComBox->AddString(L"小号字");
	pComBox->AddString(L"中号字");
	pComBox->AddString(L"大号字");
	
	/////////////////// 分别设置编辑框字体		
	memset(&lf, 0, sizeof(LOGFONT));   ///清空LOGFONT变量
	lf.lfHeight = 28;
	lstrcpy(lf.lfFaceName, _T("宋体"));
	VERIFY(m_EditDefaultFont.CreateFontIndirect(&lf));	
	theEdit.SetFont(&m_EditDefaultFont);  ///////设置默认字体
	
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 20;
	lstrcpy(lf.lfFaceName, _T("宋体"));
	VERIFY(m_EditSmallFont.CreateFontIndirect(&lf));
	
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 35;
	lstrcpy(lf.lfFaceName, _T("宋体"));
	VERIFY(m_EditMiddlingFont.CreateFontIndirect(&lf));

	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 45;
	lstrcpy(lf.lfFaceName, _T("宋体"));
	VERIFY(m_EditBigFont.CreateFontIndirect(&lf));
}

void CNoteBookView::OnSelendokCombo1() 
{
	CComboBox* pComBox = ((CMainFrame*)GetParentFrame())->pComBox;
	int  iUserSel = pComBox->GetCurSel();  ///得到选中的索引
	////////改变编辑框字体大小
	CEdit& theEdit = GetEditCtrl();		
	switch(iUserSel)
	{
	case 0:
		theEdit.SetFont(&m_EditDefaultFont);
		break;
	case 1:
		theEdit.SetFont(&m_EditSmallFont);
		break;
	case 2:
		theEdit.SetFont(&m_EditMiddlingFont);
		break;
	case 3:
		theEdit.SetFont(&m_EditBigFont);
		break;
	}
	////////更新窗口	
	theEdit.UpdateWindow();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -