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

📄 exmpcomctlview.cpp

📁 这个是我们学校用的VC++教案
💻 CPP
字号:
// ExmpComctlView.cpp : implementation of the CExmpComctlView class
//

#include "stdafx.h"
#include "ExmpComctl.h"

#include "ExmpComctlDoc.h"
#include "ExmpComctlView.h"
#include "ComctlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView

IMPLEMENT_DYNCREATE(CExmpComctlView, CView)

BEGIN_MESSAGE_MAP(CExmpComctlView, CView)
	//{{AFX_MSG_MAP(CExmpComctlView)
	ON_COMMAND(ID_TEST_COMCTL, OnTestComctl)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView construction/destruction

CExmpComctlView::CExmpComctlView()
{
	// TODO: add construction code here

}

CExmpComctlView::~CExmpComctlView()
{
}

BOOL CExmpComctlView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView drawing

void CExmpComctlView::OnDraw(CDC* pDC)
{
	CExmpComctlDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView printing

BOOL CExmpComctlView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CExmpComctlView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CExmpComctlView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView diagnostics

#ifdef _DEBUG
void CExmpComctlView::AssertValid() const
{
	CView::AssertValid();
}

void CExmpComctlView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CExmpComctlView message handlers

void  CExmpComctlView::OnTestComctl()
{
	// TODO: Add your command handler code here
	CComctlDlg  dlg;
	if (dlg.DoModal()!=IDOK)
		return;
	Invalidate();      // 使用户视图区域无效,以清除上一次画的圆
	UpdateWindow();     // 刷新用户视图区域
	CClientDC  dc(this);
	CPen  penNew, *ppenOld;
	penNew.CreatePen(PS_SOLID, dlg.m_nLineWt , RGB(0,0,0));   // 创建指定宽度的画笔
	ppenOld=dc.SelectObject(&penNew);    // 选择创建的画笔
	dc.Ellipse(0, 0, 2*dlg.m_nRadius, 2*dlg.m_nRadius);   // 根据设置的半径绘圆
	dc.SelectObject(ppenOld);    // 恢复原来的画笔
}

⌨️ 快捷键说明

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