view.h

来源:互联网 发布:windows note 编辑:程序博客网 时间:2024/06/05 03:49

// sxView.cpp : implementation of the CSxView class
//

#include "stdafx.h"
#include "sx.h"

#include "sxDoc.h"
#include "sxView.h"

#include"student.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSxView

IMPLEMENT_DYNCREATE(CSxView, CView)

BEGIN_MESSAGE_MAP(CSxView, CView)
 //{{AFX_MSG_MAP(CSxView)
 ON_WM_LBUTTONDOWN()
 ON_WM_RBUTTONDOWN()
 ON_COMMAND(AFX_ID_add, OnIDadd)
 ON_COMMAND(AFX_ID_jianshao, OnIDjianshao)
 ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
 //}}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()

/////////////////////////////////////////////////////////////////////////////
// CSxView construction/destruction

CSxView::CSxView()
{
 // TODO: add construction code here
 num=0;
 r=10;

}

CSxView::~CSxView()
{
}

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

 return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CSxView drawing

void CSxView::OnDraw(CDC* pDC)
{
 CSxDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 // TODO: add draw code for native data here
 //str.Format("计数%d",pDoc->num);
 //pDC->TextOut(1,1,str);


/* int i=1,x=10,y=10,temp=10;
 for(;i<101;++i)
 {
  str.Format("%d",i);
  pDC->TextOut(x,y,str);
  x+=30;
  if(i==temp)
  {
   y+=30;
   temp+=10;
   x=10;
  }
 }
 */
 student st1("找高三",100);
 st1.Display(pDC,20,20);
}

/////////////////////////////////////////////////////////////////////////////
// CSxView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CSxView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CSxView message handlers
 
void CSxView::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
    CSxDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 ++pDoc->num;
 pDoc->SetModifiedFlag();
 
 this->Invalidate();

 CDC*pDC=GetDC();

 pDC->Ellipse(point.x-r,point.y-r,point.x+r,point.y+r);
 
 CView::OnLButtonDown(nFlags, point);

 

 

    CStudentRecordSet  rs;
 rs.Open();
 rs AddNew();
 rs.m_ID="001"
 rs.m_Name="张三";
 rs.m_


}

void CSxView::OnRButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 CSxDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 --pDoc->num;
 pDoc->SetModifiedFlag();
 this->Invalidate();
 

 
 CView::OnRButtonDown(nFlags, point);
}

void CSxView::OnIDadd()
{
 // TODO: Add your command handler code here
 r+=10;
 //this->Invalidate();
 
}

void CSxView::OnIDjianshao()
{
 // TODO: Add your command handler code here
 r-=10;
}

void CSxView::OnEditUndo()
{
 // TODO: Add your command handler code here
 this->Invalidate();
}

原创粉丝点击