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

📄 mysdiview.cpp

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

#include "stdafx.h"
#include "Mysdi.h"

#include "MysdiDoc.h"
#include "MysdiView.h"

//#include "RadiusDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMysdiView

IMPLEMENT_DYNCREATE(CMysdiView, CView)

BEGIN_MESSAGE_MAP(CMysdiView, CView)
	//{{AFX_MSG_MAP(CMysdiView)
	ON_COMMAND(ID_EDIT_INPUTRADIUS, OnEditInputradius)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_DIALOG, OnDialog)
	// 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()

/////////////////////////////////////////////////////////////////////////////
// CMysdiView construction/destruction

CMysdiView::CMysdiView()
{
	// TODO: add construction code here
	m_nCViewRadius=0;
	pModallessDlg=NULL;
}

CMysdiView::~CMysdiView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMysdiView drawing

void CMysdiView::OnDraw(CDC* pDC)
{
	CMysdiDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	pDC->Ellipse(0,0,2*m_nCViewRadius,2*m_nCViewRadius);
}

/////////////////////////////////////////////////////////////////////////////
// CMysdiView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMysdiView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMysdiView message handlers

void CMysdiView::OnEditInputradius() 
{
	// TODO: Add your command handler code here
	if(pModallessDlg==NULL)
	{
		pModallessDlg=new CRadiusDialog;
		pModallessDlg->m_nRadius=100;   // 设置编辑框显示的初始值
		pModallessDlg->Create(IDD_RADIUS_DIALOG,NULL);  // IDD_RADIUS_DIALOG是对话框资源ID
		pModallessDlg->ShowWindow(SW_SHOW);
	}
	else
		pModallessDlg->SetActiveWindow();
}

LRESULT CMysdiView::OnDialog(WPARAM wParam,LPARAM lParam)
{
	switch(wParam)
	{
	case  IDOK:
		m_nCViewRadius=pModallessDlg->m_nRadius;  // 获得对话框编辑控件成员变量的值
		pModallessDlg->DestroyWindow();     // 销毁对话框窗口
		delete pModallessDlg;    // 删除当前的模态对话框对象
		pModallessDlg=NULL;    // 设置模态对话框不存在标志
		break;
	case  IDCANCEL:
		pModallessDlg->DestroyWindow();
		delete pModallessDlg;
		pModallessDlg=NULL;
		break;
	case  IDAPPLY:   // 保留模态对话框
		m_nCViewRadius=pModallessDlg->m_nRadius;
		break;
	}
	Invalidate();   // 刷新视图
	return 0;
}

⌨️ 快捷键说明

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