📄 工具条view.cpp
字号:
// 工具条View.cpp : implementation of the CMyView class
//
#include "stdafx.h"
#include "工具条.h"
#include "工具条Doc.h"
#include "工具条View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CView)
BEGIN_MESSAGE_MAP(CMyView, CView)
//{{AFX_MSG_MAP(CMyView)
ON_COMMAND(ID_VIEW_BOLD, OnViewBold)
ON_COMMAND(ID_VIEW_ITALIC, OnViewItalic)
ON_COMMAND(ID_VIEW_UNDERLINE, OnViewUnderline)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction
CMyView::CMyView()
{
// TODO: add construction code here
}
CMyView::~CMyView()
{
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMyView drawing
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CFont newFont;
if(m_bBold)
{newFont.CreateFont(40,
0,
0,
0,
600,
0,
0,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
"Arial");
}
else if(m_bItalic)
{newFont.CreateFont(40,
0,
0,
0,
400,
1,
0,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
"Arial");
}
else if(m_bUnderline)
{newFont.CreateFont(40,
0,
0,
0,
400,
0,
1,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
"Arial");
}
pDC->SelectObject(newFont);
pDC->TextOut(10,100,"this is an example for fontstyle");
}
/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics
#ifdef _DEBUG
void CMyView::AssertValid() const
{
CView::AssertValid();
}
void CMyView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
void CMyView::OnViewBold()
{
// TODO: Add your command handler code here
m_bBold=TRUE;
m_bItalic=FALSE;
m_bUnderline=FALSE;
InvalidateRect(NULL,TRUE);
}
void CMyView::OnViewItalic()
{
// TODO: Add your command handler code here
m_bBold=FALSE;
m_bItalic=TRUE;
m_bUnderline=FALSE;
InvalidateRect(NULL,TRUE);
}
void CMyView::OnViewUnderline()
{
// TODO: Add your command handler code here
m_bBold=FALSE;
m_bItalic=FALSE;
m_bUnderline=TRUE;
InvalidateRect(NULL,TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -