?? notebookview.cpp
字號(hào):
// 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();
////////設(shè)置窗口標(biāo)題
AfxGetMainWnd()->SetWindowText(L"記事本");
////////設(shè)置初始文件路徑變量
CEdit& theEdit = GetEditCtrl();
m_strFilePath = L"";
theEdit.SetLimitText(128 * 1024); ////////設(shè)置文本長(zhǎng)度, 單位字節(jié)
///////設(shè)置組合框大字體
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"默認(rèn)字");///
pComBox->AddString(L"小號(hào)字");
pComBox->AddString(L"中號(hào)字");
pComBox->AddString(L"大號(hào)字");
/////////////////// 分別設(shè)置編輯框字體
memset(&lf, 0, sizeof(LOGFONT)); ///清空LOGFONT變量
lf.lfHeight = 28;
lstrcpy(lf.lfFaceName, _T("宋體"));
VERIFY(m_EditDefaultFont.CreateFontIndirect(&lf));
theEdit.SetFont(&m_EditDefaultFont); ///////設(shè)置默認(rèn)字體
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();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -