实训项目
2013-07-18 18:28
99 查看
东软实训之左键+,右键-功能,并且退出提示保存
// jiView.h : interface of the CJiView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_)
#define AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CJiView : public CView
{
protected: // create from serialization only
CJiView();
DECLARE_DYNCREATE(CJiView)
// Attributes
public:
CJiDoc* GetDocument();
// Operations
public:
private:
int num;//添加成员变量
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CJiView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CJiView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CJiView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in jiView.cpp
inline CJiDoc* CJiView::GetDocument()
{ return (CJiDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_)
// jiDoc.cpp : implementation of the CJiDoc class
//
#include "stdafx.h"
#include "ji.h"
#include "jiDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJiDoc
IMPLEMENT_DYNCREATE(CJiDoc, CDocument)
BEGIN_MESSAGE_MAP(CJiDoc, CDocument)
//{{AFX_MSG_MAP(CJiDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJiDoc construction/destruction
CJiDoc::CJiDoc():num(0)//成员变量初始化
{
// TODO: add one-time construction code here
}
CJiDoc::~CJiDoc()
{
}
BOOL CJiDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;//刷新
num=0;//新建后初始值
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CJiDoc serialization
void CJiDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar<<num;//写入
// TODO: add storing code here
}
else
{
ar>>num;//读入
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CJiDoc diagnostics
#ifdef _DEBUG
void CJiDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CJiDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJiDoc commands
// jiView.cpp : implementation of the CJiView class
//
#include "stdafx.h"
#include "ji.h"
#include "jiDoc.h"
#include "jiView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJiView
IMPLEMENT_DYNCREATE(CJiView, CView)
BEGIN_MESSAGE_MAP(CJiView, CView)
//{{AFX_MSG_MAP(CJiView)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CJiView construction/destruction
CJiView::CJiView():num(0)//成员变量初始化
{
// TODO: add construction code here
}
CJiView::~CJiView()
{
}
BOOL CJiView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CJiView drawing
void CJiView::OnDraw(CDC* pDC)
{
CJiDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CString str;
str.Format("计数%d",num);//格式转换
pDC->TextOut(100,100,str);//在视图上显示
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CJiView printing
BOOL CJiView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CJiView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CJiView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CJiView diagnostics
#ifdef _DEBUG
void CJiView::AssertValid() const
{
CView::AssertValid();
}
void CJiView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CJiDoc* CJiView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJiDoc)));
return (CJiDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJiView message handlers
void CJiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CJiDoc* pDoc = GetDocument();//从ondraw中复制过来
ASSERT_VALID(pDoc);//从ondraw中复制过来
++num;//实现鼠标左键+
pDoc->SetModifiedFlag();//修改后保存提示
this->Invalidate();//刷新
CView::OnLButtonDown(nFlags, point);
}
void CJiView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CJiDoc* pDoc = GetDocument();//从ondraw中复制过来
ASSERT_VALID(pDoc);//从ondraw中复制过来
--num;//实现鼠标右键-
pDoc->SetModifiedFlag();//修改后保存提示
this->Invalidate();//刷新
CView::OnRButtonDown(nFlags, point);
}
// jiView.h : interface of the CJiView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_)
#define AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CJiView : public CView
{
protected: // create from serialization only
CJiView();
DECLARE_DYNCREATE(CJiView)
// Attributes
public:
CJiDoc* GetDocument();
// Operations
public:
private:
int num;//添加成员变量
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CJiView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CJiView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CJiView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in jiView.cpp
inline CJiDoc* CJiView::GetDocument()
{ return (CJiDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_JIVIEW_H__EBC5C1EC_CA4F_47A4_82FE_1022029E2AD2__INCLUDED_)
// jiDoc.cpp : implementation of the CJiDoc class
//
#include "stdafx.h"
#include "ji.h"
#include "jiDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJiDoc
IMPLEMENT_DYNCREATE(CJiDoc, CDocument)
BEGIN_MESSAGE_MAP(CJiDoc, CDocument)
//{{AFX_MSG_MAP(CJiDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJiDoc construction/destruction
CJiDoc::CJiDoc():num(0)//成员变量初始化
{
// TODO: add one-time construction code here
}
CJiDoc::~CJiDoc()
{
}
BOOL CJiDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;//刷新
num=0;//新建后初始值
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CJiDoc serialization
void CJiDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar<<num;//写入
// TODO: add storing code here
}
else
{
ar>>num;//读入
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CJiDoc diagnostics
#ifdef _DEBUG
void CJiDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CJiDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJiDoc commands
// jiView.cpp : implementation of the CJiView class
//
#include "stdafx.h"
#include "ji.h"
#include "jiDoc.h"
#include "jiView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJiView
IMPLEMENT_DYNCREATE(CJiView, CView)
BEGIN_MESSAGE_MAP(CJiView, CView)
//{{AFX_MSG_MAP(CJiView)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CJiView construction/destruction
CJiView::CJiView():num(0)//成员变量初始化
{
// TODO: add construction code here
}
CJiView::~CJiView()
{
}
BOOL CJiView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CJiView drawing
void CJiView::OnDraw(CDC* pDC)
{
CJiDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CString str;
str.Format("计数%d",num);//格式转换
pDC->TextOut(100,100,str);//在视图上显示
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CJiView printing
BOOL CJiView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CJiView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CJiView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CJiView diagnostics
#ifdef _DEBUG
void CJiView::AssertValid() const
{
CView::AssertValid();
}
void CJiView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CJiDoc* CJiView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJiDoc)));
return (CJiDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJiView message handlers
void CJiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CJiDoc* pDoc = GetDocument();//从ondraw中复制过来
ASSERT_VALID(pDoc);//从ondraw中复制过来
++num;//实现鼠标左键+
pDoc->SetModifiedFlag();//修改后保存提示
this->Invalidate();//刷新
CView::OnLButtonDown(nFlags, point);
}
void CJiView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CJiDoc* pDoc = GetDocument();//从ondraw中复制过来
ASSERT_VALID(pDoc);//从ondraw中复制过来
--num;//实现鼠标右键-
pDoc->SetModifiedFlag();//修改后保存提示
this->Invalidate();//刷新
CView::OnRButtonDown(nFlags, point);
}
相关文章推荐
- 暑期项目开发实训 Day25
- 东软JavaWeb实训记-DAY9-小组项目开发实践(仿知乎首页登录页canvas小球特效)
- 项目实训-千寻-服务端框架搭建
- 程序设计实训项目三 电子词典
- 程序设计实训报告 项目2.2
- 暑期项目实训之健康宝APP(一)
- (项目)AR电子书系统创新实训第六周(1)
- 实训项目-银行储蓄业务管理系统2015/07/15
- android 项目实训——通讯录(未完版)
- 实训项目3
- [项目实训]Django学习
- 自然语言交流系统 phxnet团队 创新实训 项目博客 (三)
- 自然语言交流系统 phxnet团队 创新实训 项目博客 (十四)
- 暑期项目开发实训 Day4
- 【雪野实训记录】Oracle聊天室-L1阶段项目案例
- [项目实训]5.25 数据库重新正向生成及新表设计
- 【项目实训-银行系统】
- C++项目实训:银行储蓄系统
- Java实训项目--影碟管理软件
- 结对项目实训——电梯调度