📄 dialog~3.cpp
字号:
// DialogBarView.cpp : CDialogBarView 类的实现
//
#include "stdafx.h"
#include "DialogBar.h"
#include "DialogBarDoc.h"
#include "DialogBarView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CDialogBarView
IMPLEMENT_DYNCREATE(CDialogBarView, CView)
BEGIN_MESSAGE_MAP(CDialogBarView, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
//“红色”单选按钮的消息映射
ON_BN_CLICKED(IDC_RED,OnRed)
//“黄色”单选按钮的消息映射
ON_BN_CLICKED(IDC_YELLOW,OnYellow)
//“绿色”单选按钮的消息映射
ON_BN_CLICKED(IDC_GREEN,OnGreen)
//“设置背景”按钮的消息映射
ON_BN_CLICKED(IDC_BACKGROUND,OnBnClickedBackGround)
END_MESSAGE_MAP()
// CDialogBarView 构造/销毁
CDialogBarView::CDialogBarView()
{
// TODO: 在此处添加构造代码
color=RGB(255,255,255);
}
CDialogBarView::~CDialogBarView()
{
}
BOOL CDialogBarView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// CDialogBarView 绘制
void CDialogBarView::OnDraw(CDC* pDC)
{
CDialogBarDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
//声明一距形对象
CRect rcClient;
//获取客户区的大小
GetClientRect(&rcClient);
//以设定的颜色值填充客户区已显示背景
pDC->FillSolidRect(&rcClient,color);
}
// CDialogBarView 打印
BOOL CDialogBarView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CDialogBarView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印前添加额外的初始化
}
void CDialogBarView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印后添加清除过程
}
// CDialogBarView 诊断
#ifdef _DEBUG
void CDialogBarView::AssertValid() const
{
CView::AssertValid();
}
void CDialogBarView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDialogBarDoc* CDialogBarView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDialogBarDoc)));
return (CDialogBarDoc*)m_pDocument;
}
#endif //_DEBUG
// CDialogBarView 消息处理程序
void CDialogBarView::OnRed()
{
//设置颜色值为红色
color=RGB(255,0,0);
}
void CDialogBarView::OnGreen()
{
//设置颜色值为绿色
color=RGB(0,255,0);
}
void CDialogBarView::OnYellow()
{
//设置颜色值为黄色
color=RGB(255,255,0);
}
void CDialogBarView::OnBnClickedBackGround()
{
//强制窗口重绘
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -