MyView.cpp

// myView.cpp : implementation of the CMyView class
//

#include "stdafx.h"
#include "my.h"

#include"MyDialog1.h"

#include "myDoc.h"
#include "myView.h"
#include"StudentRecordset.h"
//#include<afxdb.h>
//#include"StudentRecordset.h"
#include"Student.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_WM_LBUTTONDOWN()
 ON_WM_RBUTTONDOWN()
 ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)
 //}}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()

/////////////////////////////////////////////////////////////////////////////
// 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
 /*CStudent st1("找高三",100);
 st1.display(pDC,20,20);*/
 pDC->TextOut(20, 20, str);


}

/////////////////////////////////////////////////////////////////////////////
// CMyView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// 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::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default

/* CStudentRecordset rs;
 rs.Open();
 rs.AddNew();
 rs.m_ID="002";
 rs.m_Name="张三";
 rs.m_english=100;
 rs.Update();
 rs.Close();*/

 /*if(!rs.Update())
 {
  Message("error");
 }*/

 


 CView::OnLButtonDown(nFlags, point);
}

void CMyView::OnRButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 
 CView::OnRButtonDown(nFlags, point);
}

void CMyView::OnMenuitem32771()
{
 //CMyDialog1 my;
 //my.DoModal();
 // TODO: Add your command handler code here
 CMyDialog1 my;
 if (my.DoModal() == IDOK)
 {
  str1="姓名:"+my.m_strName;
  str2="  学号: "+my.m_strenglish;
  str3="  成绩: "+my.m_EdictID;
  Invalidate();
 }

 

 
}

你可能感兴趣的:(MyView.cpp)