📄 sdsdview.cpp
字号:
// sdsdView.cpp : implementation of the CSdsdView class
//
#include "stdafx.h"
#include "sdsd.h"
#include "sdsdDoc.h"
#include "sdsdView.h"
#include "seqlist.h"
#include "insert.h"
#include "delete.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSdsdView
IMPLEMENT_DYNCREATE(CSdsdView, CView)
BEGIN_MESSAGE_MAP(CSdsdView, CView)
//{{AFX_MSG_MAP(CSdsdView)
ON_COMMAND(ID_MYINPUT, OnMyinput)
ON_COMMAND(ID_MYINSERT, OnMyinsert)
ON_COMMAND(ID_MYDELETE, OnMydelete)
ON_WM_TIMER()
ON_WM_CANCELMODE()
ON_WM_CAPTURECHANGED()
ON_WM_CHAR()
ON_WM_CONTEXTMENU()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CSdsdView construction/destruction
CSdsdView::CSdsdView()
{
// TODO: add construction code here
istep=0;
}
CSdsdView::~CSdsdView()
{
}
BOOL CSdsdView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CSdsdView drawing
void CSdsdView::OnDraw(CDC* pDC)
{
CSdsdDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SelectObject(new CBrush(RGB(255,255,0)));
pDC->Rectangle(90,40,580,300);
//pDC->Rectangle(5,18,55,24);
// pDC->TextOut(40,40,"fuck you");
/* for(int i=0;i<10;i++)
{
pDC->Rectangle(20+40*i,50,60+40*i,90);
CString str;
str.Format("%d",i);
pDC->TextOut(20+40*i+12,20,str);
}*/
YANG.Drawed(pDC);
pDC->MoveTo(90,40);
pDC->LineTo(580,40);
pDC->MoveTo(90,300);
pDC->LineTo(580,300);
pDC->MoveTo(90,40);
pDC->LineTo(90,300);
pDC->MoveTo(580,40);
pDC->LineTo(580,300);
pDC->TextOut(92,50,"(顺序表功能显示区)");
int cHeight;
UINT position=0;
CFont font;
cHeight=16;
font.CreateFont(cHeight,0,0,0,FW_BOLD,TRUE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,"宋体");
// pDC->DrawText()
CFont*oldFont=pDC->SelectObject(&font);
pDC->TextOut(325,290,"06080266");
pDC->SelectObject(oldFont);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CSdsdView printing
BOOL CSdsdView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CSdsdView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CSdsdView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CSdsdView diagnostics
#ifdef _DEBUG
void CSdsdView::AssertValid() const
{
CView::AssertValid();
}
void CSdsdView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CSdsdDoc* CSdsdView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSdsdDoc)));
return (CSdsdDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSdsdView message handlers
void CSdsdView::OnMyinput()
{
// TODO: Add your command handler code here
CInputDlg dlg;
int nRet=dlg.DoModal();
if(nRet=IDOK)
{
YANG.list[0].data=dlg.m_nX0;
YANG.list[1].data=dlg.m_nX1;
YANG.list[2].data=dlg.m_nX2;
YANG.list[3].data=dlg.m_nX3;
YANG.list[4].data=dlg.m_nX4;
YANG.list[5].data=dlg.m_nX5;
YANG.list[6].data=dlg.m_nX6;
YANG.list[7].data=dlg.m_nX7;
YANG.list[8].data=dlg.m_nX8;
YANG.list[9].data=dlg.m_nX9;
YANG.tail=dlg.m_ntail-1;
}
CDC*pDC=GetDC();
YANG.Drawed(pDC);
}
void CSdsdView::OnMyinsert()
{
// TODO: Add your command handler code here
CInsert dlg;
int nRet=dlg.DoModal();
if(nRet==IDOK)
{
istep=dlg.m_istep;
if(istep==0)
YANG.Insert(dlg.m_nNum,dlg.m_nTemp);
else
{
WZ=dlg.m_nNum;
YS=dlg.m_nTemp;
DQ=YANG.tail;
SetTimer(1,1000,NULL);
YANG.tail++;
}
}
// if(nRet==)
CDC*pDC=GetDC();
YANG.Drawed(pDC);
}
void CSdsdView::OnMydelete()
{
// TODO: Add your command handler code here
CDelete dlg;
int nRet=dlg.DoModal();
if(nRet==IDOK)
{
istep=dlg.m_istep;
if(istep==0)
{
YANG.Delete(dlg.m_nAddr);
}
else
{
WZ2=dlg.m_nAddr;
DQ=dlg.m_nAddr;
SetTimer(2,1000,NULL);
YANG.tail--;
}
}
CDC*pDC=GetDC();
YANG.Drawed(pDC);
}
void CSdsdView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDC*pDC=GetDC();
switch(nIDEvent)
{
case 1:
if(DQ>=WZ)
{
YANG.list[DQ+1].data=YANG.list[DQ].data;
YANG.list[DQ].data="";
DQ--;
YANG.Drawed(pDC);
}
else
{
YANG.list[WZ].data=YS;
YANG.Drawed(pDC);
KillTimer(1);
MessageBox("插入已经完成");
}
break;
case 2:
if(DQ<=YANG.tail+1)
{
if(DQ==WZ2)
{
YANG.list[DQ].data="";
YANG.Drawed(pDC);
DQ++;
}
else
{
YANG.list[DQ-1].data=YANG.list[DQ].data;
YANG.list[DQ].data="";
DQ++;
YANG.Drawed(pDC);
}
}
else
{
KillTimer(2);
MessageBox("删除完成");
YANG.Drawed(pDC);
}
break;
}
CView::OnTimer(nIDEvent);
}
void CSdsdView::OnCancelMode()
{
CView::OnCancelMode();
// TODO: Add your message handler code here
}
void CSdsdView::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
CView::OnCaptureChanged(pWnd);
}
void CSdsdView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CView::OnChar(nChar, nRepCnt, nFlags);
}
void CSdsdView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -