implement
vmware虚拟机绿色版-网络嗅探
2023年4月1日发(作者:dos删除命令)路漫漫其修远兮,吾将上下而求索-百度文库
11
protected:
//{{AFX_MSG(CMainFrame)
afx_msgintOnCreate(LPCREATESTRUCTlpCreateStruct);
afx_msgvoidOnMenuInPut();
afx_msgvoidOnMenuCreat();
afx_msgvoidOnMenuPrint();
afx_msgvoidOnMenuCurve();
afx_msgvoidOnMenuHistogram();
afx_msgvoidOnMenuCake();
afx_msgvoidOnCorlo();
afx_msgvoidOnMenuBig();
afx_msgvoidOnMenuSmall();
afx_msgvoidOnMenuClose();
afx_msgvoidOnMenuOpen();
afx_msgvoidOnMenuQuxian();
afx_msgvoidOnMENUpie();
afx_msgvoidOnMenuZhuzhuang();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//:implementationoftheCMainFrameclass
//
#include"stdafx.h"
#include"GraphDraw.h"
#include"MainFrm.h"
#include"iostream.h"
#include"fstream.h"
#include"string.h"
#include"dlg.h"
#include"GraphDrawView.h"
#include"GraphDrawdoc.h"
externCGraphDrawApptheApp;
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
#include"GraphDrawdoc.h"
路漫漫其修远兮,吾将上下而求索-百度文库
22
externCGraphDrawApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame,CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_MENU_IN,OnMenuInPut)
ON_COMMAND(ID_MENU_CREAT,OnMenuCreat)
ON_COMMAND(ID_MENU_PRINT,OnMenuPrint)
ON_COMMAND(ID_MENU_CURVE,OnMenuCurve)
ON_COMMAND(ID_MENU_HISTOGRAM,OnMenuHistogram)
ON_COMMAND(ID_MENU_CAKE,OnMenuCake)
ON_COMMAND(ID_CORLO,OnCorlo)
ON_COMMAND(ID_MENU_BIG,OnMenuBig)
ON_COMMAND(ID_MENU_SMALL,OnMenuSmall)
ON_COMMAND(ID_MENU_CLOSE,OnMenuClose)
ON_COMMAND(ID_MENU_OPEN,OnMenuOpen)
ON_COMMAND(ID_MENU_QUXIAN,OnMenuQuxian)
ON_COMMAND(ID_MENU_pie,OnMENUpie)
ON_COMMAND(ID_MENU_ZHUZHUANG,OnMenuZhuzhuang)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
staticUINTindicators[]=
{
ID_SEPARATOR,//statuslineindicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
//CMainFrameconstruction/destruction
CMainFrame::CMainFrame()
{
//TODO:addmemberinitializationcodehere
}
路漫漫其修远兮,吾将上下而求索-百度文库
33
CMainFrame::~CMainFrame()
{
}
intCMainFrame::OnCreate(LPCREATESTRUCTlpCreateStruct)
{
if(CFrameWnd::OnCreate(lpCreateStruct)==-1)
return-1;
if(!m_Ex(this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_TOP
|CBRS_GRIPPER|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)||
!m_olBar(IDR_MAINFRAME))
{
TRACE0("Failedtocreatetoolbarn");
return-1;//failtocreate
}
if(!m_(this)||
!m_icators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failedtocreatestatusbarn");
return-1;//failtocreate
}
//TODO:Deletethesethreelinesifyoudon'twantthetoolbarto
//bedockable
m_Docking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return0;
}
BOOLCMainFrame::PreCreateWindow(CREATESTRUCT&cs)
{
if(!CFrameWnd::PreCreateWindow(cs))
returnFALSE;
//TODO:ModifytheWindowclassorstylesherebymodifying
//theCREATESTRUCTcs
returnTRUE;
}
路漫漫其修远兮,吾将上下而求索-百度文库
44
/////////////////////////////////////////////////////////////////////////////
//CMainFramediagnostics
#ifdef_DEBUG
voidCMainFrame::AssertValid()const
{
CFrameWnd::AssertValid();
}
voidCMainFrame::Dump(CDumpContext&dc)const
{
CFrameWnd::Dump(dc);
}
#endif//_DEBUG
/////////////////////////////////////////////////////////////////////////////
//CMainFramemessagehandlers
voidCMainFrame::OnMenuInPut()//从文本中读取数据
{
//TODO:Addyourcommandhandlercodehere
CFileDialogdlg(TRUE,"SQL","*.txt",
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"*.*",NULL);//弹出文件对话框
l();
//记录文件途径
filename=hName();
//更新对话框
this->UpdateData(FALSE);
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
ifstreamin(filename);//读取文件
CStrings;//定义字符串
CStringstr="";
inti=0;
for(intk=0;k<20;k++)
pDoc->score[k]=NULL;//初始化
in>>pDoc->x>>pDoc->y;
in>>pDoc->name>>pDoc->score[0];//读入数据
if(())
路漫漫其修远兮,吾将上下而求索-百度文库
55
{
::AfxMessageBox("无数据!或者数据不符合要求!");//判断是否有数据,是否是对称的
数据
}
else//不只一个数继续
{
pDoc->=pDoc->x;//把名字传给坐标
pDoc->=pDoc->y;
str="数据读取成功!n";
while(!())
{
//str+="(";
("%s",pDoc->name);//转换类型
str+=s;
str+="";
("%d",pDoc->score[i]);//转换类型
str+=s;
//str+=")";
str+="";
i++;
in>>pDoc->name>>pDoc->score[i];//继续读取
pDoc->num=i+1;
}
("%s",pDoc->name);
str+=s;
str+="";
("%d",pDoc->score[i]);
str+=s;
str+="";
("%d",pDoc->num);
pDoc->=s;
pDoc->="100";
::AfxMessageBox(str);//在消息框输出
}
}
voidCMainFrame::OnMenuCreat()//创建坐标系
{
//TODO:Addyourcommandhandlercodehere
CDlgdlg;
l();
}
路漫漫其修远兮,吾将上下而求索-百度文库
66
voidCMainFrame::OnMenuPrint()//影射画坐标系
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=1;//标志赋值
pDoc->Draw();//调用画图
}
voidCMainFrame::OnMenuCurve()//影射画曲线图
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=5;//标志赋值
pView->Flag=0;
pView->SetTimer(1,100,NULL);
pView->Invalidate();
}
voidCMainFrame::OnMenuHistogram()//影射画柱状图
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=6;//标志赋值
pView->Flag=0;
pView->SetTimer(2,10,NULL);
pView->Invalidate();
}
voidCMainFrame::OnMenuCake()//影射画饼状图
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=7;
pView->Flag=0;
路漫漫其修远兮,吾将上下而求索-百度文库
77
pDoc->();
pView->SetTimer(3,300,NULL);
pView->Invalidate();
//pDoc->Draw();//调用画图
}
voidCMainFrame::OnCorlo()//颜色
{
//TODO:Addyourcommandhandlercodehere
CColorDialogdlg;
l();
//or();
}
voidCMainFrame::OnMenuBig()//放大
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->Flag=22;//可以进行放大图形
if(pView->flag==5)//重画原来的图形
pView->flag=2;
if(pView->flag==6)
pView->flag=3;
if(pView->flag==7)
pView->flag=4;
pView->Invalidate();
}
voidCMainFrame::OnMenuSmall()//缩小
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->Flag=33;//可以进行缩小图形
if(pView->flag==5)//重画原来的图形
pView->flag=2;
if(pView->flag==6)
pView->flag=3;
路漫漫其修远兮,吾将上下而求索-百度文库
88
if(pView->flag==7)
pView->flag=4;
pView->Invalidate();
}
voidCMainFrame::OnMenuClose()//关闭移动
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->Flag=0;//把移动关闭
}
voidCMainFrame::OnMenuOpen()//开启移动
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->Flag=11;//可以进行移动图形
if(pView->flag==5)//重画原来的图形
pView->flag=2;
if(pView->flag==6)
pView->flag=3;
if(pView->flag==7)
pView->flag=4;
pView->Invalidate();
}
voidCMainFrame::OnMenuQuxian()
{
//TODO:Addyourcommandhandlercodehere
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=2;//静态画曲线
pView->Invalidate();
}
voidCMainFrame::OnMENUpie()
路漫漫其修远兮,吾将上下而求索-百度文库
99
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=4;//静态画饼
pDoc->();
pView->Invalidate();
}
voidCMainFrame::OnMenuZhuzhuang()
{
//TODO:Addyourcommandhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
CGraphDrawView*pView=(CGraphDrawView*)pFrame->GetActiveView();
pView->flag=3;//静态画柱状图
pView->Invalidate();
}
public:
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CGraphDrawView)
public:
virtualvoidOnDraw(CDC*pDC);//overriddentodrawthisview
virtualBOOLPreCreateWindow(CREATESTRUCT&cs);
protected:
virtualBOOLOnPreparePrinting(CPrintInfo*pInfo);
virtualvoidOnBeginPrinting(CDC*pDC,CPrintInfo*pInfo);
virtualvoidOnEndPrinting(CDC*pDC,CPrintInfo*pInfo);
//}}AFX_VIRTUAL
//Implementation
public:
intFlag;
CPointm_point;
intFLAG;
intflag;//定义一个标志变量
virtual~CGraphDrawView();
#ifdef_DEBUG
virtualvoidAssertValid()const;
virtualvoidDump(CDumpContext&dc)const;
路漫漫其修远兮,吾将上下而求索-百度文库
1010
#endif
protected:
//Generatedmessagemapfunctions
protected:
//{{AFX_MSG(CGraphDrawView)
afx_msgvoidOnTimer(UINTnIDEvent);
afx_msgvoidOnClean();
afx_msgvoidOnLButtonDown(UINTnFlags,CPointpoint);
afx_msgvoidOnLButtonUp(UINTnFlags,CPointpoint);
afx_msgvoidOnMouseMove(UINTnFlags,CPointpoint);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
路漫漫其修远兮,吾将上下而求索-百度文库
1111
//:implementationoftheCGraphDrawViewclass
//
#include"stdafx.h"
#include"GraphDraw.h"
#include"GraphDrawDoc.h"
#include"GraphDrawView.h"
#include"mainfrm.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
externCGraphDrawApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawView
IMPLEMENT_DYNCREATE(CGraphDrawView,CView)
BEGIN_MESSAGE_MAP(CGraphDrawView,CView)
//{{AFX_MSG_MAP(CGraphDrawView)
ON_WM_TIMER()
ON_COMMAND(ID_CLREN,OnClean)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
//Standardprintingcommands
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()
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawViewconstruction/destruction
CGraphDrawView::CGraphDrawView()
{
//TODO:addconstructioncodehere
flag=0;//初始化
路漫漫其修远兮,吾将上下而求索-百度文库
1212
FLAG=0;
Flag=0;
m_point=(0,0);
}
CGraphDrawView::~CGraphDrawView()
{
}
BOOLCGraphDrawView::PreCreateWindow(CREATESTRUCT&cs)
{
//TODO:ModifytheWindowclassorstylesherebymodifying
//theCREATESTRUCTcs
returnCView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawViewdrawing
voidCGraphDrawView::OnDraw(CDC*pDC)
{
CGraphDrawDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
switch(flag)
{
case1://重画坐标系
pDoc->(pDC);
break;
case2://重画曲线图
if(pDoc->score[0]!=NULL)
{
pDoc->(pDC);
pDoc->Xian(pDC);
}
break;
case3://重画柱状图
if(pDoc->score[0]!=NULL)
{
pDoc->(pDC);
pDoc->uZhuang(pDC);
}
路漫漫其修远兮,吾将上下而求索-百度文库
1313
break;
case4://重画饼状图
if(pDoc->score[0]!=NULL)
{
pDoc->e(pDC);
}
break;
case5:
if(pDoc->score[0]!=NULL)
{
pDoc->(pDC);
}
case6:
if(pDoc->score[0]!=NULL)
{
pDoc->(pDC);
}
case7:
if(pDoc->score[0]!=NULL)
{
}
}
//TODO:adddrawcodefornativedatahere
}
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawViewprinting
BOOLCGraphDrawView::OnPreparePrinting(CPrintInfo*pInfo)
{
//defaultpreparation
returnDoPreparePrinting(pInfo);
}
voidCGraphDrawView::OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
{
路漫漫其修远兮,吾将上下而求索-百度文库
1414
//TODO:addextrainitializationbeforeprinting
}
voidCGraphDrawView::OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
{
//TODO:addcleanupafterprinting
}
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawViewdiagnostics
#ifdef_DEBUG
voidCGraphDrawView::AssertValid()const
{
CView::AssertValid();
}
voidCGraphDrawView::Dump(CDumpContext&dc)const
{
CView::Dump(dc);
}
CGraphDrawDoc*CGraphDrawView::GetDocument()//non-debugversionisinline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGraphDrawDoc)));
return(CGraphDrawDoc*)m_pDocument;
}
#endif//_DEBUG
/////////////////////////////////////////////////////////////////////////////
//CGraphDrawViewmessagehandlers
voidCGraphDrawView::OnTimer(UINTnIDEvent)//时间控制器
{
//TODO:Addyourmessagehandlercodehereand/orcalldefault
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
if(nIDEvent==1)//用时间控制画曲线图
{
CDC*pDC=this->GetDC();
if(pDoc->!=""&&pDoc->!=""&&pDoc->!=""&&pDoc->!="")
路漫漫其修远兮,吾将上下而求索-百度文库
1515
pDoc->rve(pDC);//调用画曲线图
this->ReleaseDC(pDC);
if(pDoc->==pDoc->num-1)
{
KillTimer(1);//停止时间
pDoc->=0;//把循环次数化零
}
}
if(nIDEvent==2)//用时间控制画柱状图
{
CDC*pDC=this->GetDC();
if(pDoc->!=""&&pDoc->!=""&&pDoc->!=""&&pDoc->!="")
pDoc->stogram(pDC);//调用画柱状图
this->ReleaseDC(pDC);
if(pDoc->==50)
{
KillTimer(2);//停止时间
pDoc->=0;//把循环次数化零
}
}
if(nIDEvent==3)//用时间控制画饼状图
{
CDC*pDC=this->GetDC();
if(pDoc->!=""&&pDoc->!=""&&pDoc->!=""&&pDoc->!="")
pDoc->ke(pDC);//调用画饼状图]
this->ReleaseDC(pDC);
if(pDoc->==5)
{
KillTimer(3);//停止时间
CDC*pDC=this->GetDC();
pDoc->e(pDC);
this->ReleaseDC(pDC);
pDoc->=0;//把循环次数化零
}
}
CView::OnTimer(nIDEvent);
路漫漫其修远兮,吾将上下而求索-百度文库
1616
}
voidCGraphDrawView::OnClean()//清除屏幕
{
//TODO:Addyourcommandhandlercodehere
CDC*pDC=GetDC();
pDC->Rectangle(-1,-1,2000,2000);//画矩形
ReleaseDC(pDC);
}
voidCGraphDrawView::OnLButtonDown(UINTnFlags,CPointpoint)
{
//TODO:Addyourmessagehandlercodehereand/orcalldefault
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
HCURSORm_hcursor;
if(Flag==11)//驱动移动图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//FLAG=1;
m_point.x=point.x-pDoc->c.x0;//点下的点与坐标原点的差
m_point.y=point.y-pDoc->c.y0;
}
//else
//FLAG=0;
}
if(Flag==22)//驱动放大图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{//改变坐标的比例
pDoc->=pDoc->*20/17;
pDoc->c.x0=(int)(pDoc->c.x0-pDoc->/25);
pDoc->c.y0=(int)(pDoc->c.y0+pDoc->/25);
pDoc->Draw();//重画
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
SetCursor(m_hcursor);
路漫漫其修远兮,吾将上下而求索-百度文库
1717
}
}
if(Flag==33)//驱动缩小图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//改变坐标的比例
pDoc->=pDoc->*17/20;
pDoc->c.x0=(int)(pDoc->c.x0+pDoc->/25);
pDoc->c.y0=(int)(pDoc->c.y0-pDoc->/25);
pDoc->Draw();//重画
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_NO);
SetCursor(m_hcursor);
}
}
CView::OnLButtonDown(nFlags,point);
}
voidCGraphDrawView::OnLButtonUp(UINTnFlags,CPointpoint)
{
//TODO:Addyourmessagehandlercodehereand/orcalldefault
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
HCURSORm_hcursor;
if(Flag==11)//移动图形
{
pDoc->c.x0=point.x-m_point.x;
pDoc->c.y0=point.y-m_point.y;
pDoc->Draw();//重画
//FLAG=FALSE;
}
if(Flag==22)//放大图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
SetCursor(m_hcursor);
}
路漫漫其修远兮,吾将上下而求索-百度文库
1818
}
if(Flag==33)//缩小图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_NO);
SetCursor(m_hcursor);
}
}
CView::OnLButtonUp(nFlags,point);
}
voidCGraphDrawView::OnMouseMove(UINTnFlags,CPointpoint)
{
//TODO:Addyourmessagehandlercodehereand/orcalldefault
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
HCURSORm_hcursor;
if(Flag==11)//移动图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_SIZEALL);
SetCursor(m_hcursor);
}
}
if(Flag==22)//放大图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
SetCursor(m_hcursor);
}
路漫漫其修远兮,吾将上下而求索-百度文库
1919
}
if(Flag==33)//缩小图形
{
if(point.x>pDoc->c.x0&&point.xc.x0+pDoc->)&&point.y>(pDoc->c.y0-pDoc-
>)&&point.yc.y0)
{
//设置鼠标属性
m_hcursor=AfxGetApp()->LoadStandardCursor(IDC_NO);
SetCursor(m_hcursor);
}
}
CView::OnMouseMove(nFlags,point);
}
//Graph.h:interfacefortheCGraphclass.
//
//////////////////////////////////////////////////////////////////////
#if!defined(AFX_GRAPH_H__B8E3BC31_3EB6_47DA_AD33_614F0BEE9868__INCLUDED_)
#defineAFX_GRAPH_H__B8E3BC31_3EB6_47DA_AD33_614F0BEE9868__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
classCGraph
{
public:
voidDrawZhuZhuang(CDC*pDC);
voidDrawQuXian(CDC*pDC);
intgood[5];
voidPaiXu();
inttime;
CPointtoppoint;
CPointbottompoint;
voidDrawCake(CDC*pDC);
voidDrawHistogram(CDC*pDC);
voidDrawCurve(CDC*pDC);
voidDrawPie(CDC*pDC);
路漫漫其修远兮,吾将上下而求索-百度文库
2020
CGraph();
virtual~CGraph();
};
#endif//!defined(AFX_GRAPH_H__B8E3BC31_3EB6_47DA_AD33_614F0BEE9868__INCLUDED_)
//:implementationoftheCGraphclass.
//
//////////////////////////////////////////////////////////////////////
#include"stdafx.h"
#include"GraphDraw.h"
#include"Graph.h"
#include"mainfrm.h"
#include"Graphdrawdoc.h"
#include"math.h"
#ifdef_DEBUG
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#definenewDEBUG_NEW
#endif
externCGraphDrawApptheApp;
//////////////////////////////////////////////////////////////////////
//Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGraph::CGraph()
{
//CMainFrame*pFrame=(CMainFrame*)nWnd();
//CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
toppoint.x=100;
toppoint.y=100;
bottompoint.x=600;
bottompoint.y=400;
time=0;
for(inti=0;i<5;i++)
good[i]=0;
}
CGraph::~CGraph()
路漫漫其修远兮,吾将上下而求索-百度文库
2121
{
}
voidCGraph::DrawCurve(CDC*pDC)//画曲线图
{
inttemp=0;
inth=0;
floatz=0;
CPenpen;//定义画笔
CBrushbrush;
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
if(pDoc->score[0]==NULL)//判断是否读入了数据
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
h=(int)((pDoc->*9)/(pDoc->num*10));
z=(pDoc->*9)/1000;
Object();//清除画笔颜色
Pen(PS_SOLID,2,23456*(time+1));//创建画笔
pDC->SelectObject(&pen);//选择画笔
pDC->Ellipse(((time+1)*h+pDoc->c.x0)-2,(pDoc->c.y0-(int)(pDoc->score[time]*z))-2,(pDoc->c
.x0+(time+1)*h)+2,(pDoc->c.y0-(int)(pDoc->score[time]*z))+2);
pDC->MoveTo((time+1)*h+pDoc->c.x0,pDoc->c.y0-(int)(pDoc->score[time]*z));//画线
time++;
pDC->LineTo((time+1)*h+pDoc->c.x0,pDoc->c.y0-(int)(pDoc->score[time]*z));
SolidBrush(25555*(time+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Ellipse(((time+1)*h+pDoc->c.x0)-2,(pDoc->c.y0-(int)(pDoc->score[time]*z))-2,(pDoc->c
.x0+(time+1)*h)+2,(pDoc->c.y0-(int)(pDoc->score[time]*z))+2);
Object();//刷新颜色
}
}
voidCGraph::DrawHistogram(CDC*pDC)//画柱状图
{
路漫漫其修远兮,吾将上下而求索-百度文库
2222
intFlag=1;
CPenpen;//定义画笔
CBrushbrush;//定义画刷
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
if(pDoc->score[0]==NULL)//判断是否读入了数据
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
intk[20];
intt;
floatz;
t=(int)((pDoc->*9)/(pDoc->num*10));
z=(pDoc->*9)/1000;
for(inti=0;inum;i++)
{
k[i]=(int)(((int)(pDoc->score[i]*z)*(time+1))/50);
Object();//清除画笔颜色
Pen(PS_SOLID,1,2567*(i+1));//创建画笔
pDC->SelectObject(&pen);//选择画笔
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Rectangle((i+1)*t+pDoc->c.x0-4,pDoc->c.y0-k[i],(i+1)*t+pDoc->c.x0+4,pDoc->c.y0);
Object();//刷新颜色
}
time++;
}
}
voidCGraph::DrawCake(CDC*pDC)//画饼状图
{
//floattemp;
doublepie=3.1415926;//定义圆周率的值
CBrushbrush;//定义画刷
CPenpen;//定义画笔
CPointfpoint;//定义画弧的起点
CPointlpoint;//定义画弧的终点
CPointmpoint;//椭圆圆心
structtagRECTrect;//矩形坐标点
路漫漫其修远兮,吾将上下而求索-百度文库
2323
intr;//椭圆的长半径
intsum=0;//等级之和
CStrings="";//输出的字符串
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
toppoint.x=(int)(pDoc->c.x0-(pDoc->*0.2));
toppoint.y=pDoc->c.y0-(int)pDoc->;
bottompoint.x=(int)(pDoc->c.x0+(pDoc->*1.2));
bottompoint.y=pDoc->c.y0;
r=(int)(bottompoint.y-toppoint.y)/2;
//矩形坐标点的初始化
=bottompoint.y;
=toppoint.x;
=bottompoint.x;
=toppoint.y;
//椭圆原点初始化
mpoint.x=(bottompoint.x+toppoint.x)/2;
mpoint.y=(bottompoint.y+toppoint.y)/2;
//判断是否读入数据
if(pDoc->score[0]==NULL)
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
fpoint.x=bottompoint.x;//初始化起点
fpoint.y=mpoint.y;//(bottompoint.y-toppoint.y)/2+toppoint.y;
for(inti=0;i<=time;i++)//画饼状图
{
if(i==0)
{
for(inti=0;i<5;i++)
{
switch(i)
{
case0:s="优秀";
break;
case1:s="良好";
break;
case2:s="中等";
break;
case3:s="及格";
break;
case4:s="挂科";
路漫漫其修远兮,吾将上下而求索-百度文库
2424
break;
}
pDC->TextOut(toppoint.x+80*i-40,toppoint.y-30,s);
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Rectangle(toppoint.x+80*i,toppoint.y-30,toppoint.x+80*i+20,toppoint.y-15);
Object();//刷新颜色
}
}
if(good[i]>0)
{
sum+=good[i];
lpoint.x=mpoint.x+(int)(r*cos(2*pie*sum/pDoc->num));//初始化终点
lpoint.y=mpoint.y-(int)(r*sin(2*pie*sum/pDoc->num));
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Pie(toppoint.x,toppoint.y+10,bottompoint.x,bottompoint.y+10,fpoint.x,fpoint.y+10,lp
oint.x,lpoint.y+10);
pDC->Pie(&rect,fpoint,lpoint);
Object();//刷新颜色
fpoint=lpoint;//把第一个的终点作为下一次画饼的起点
}
}
time++;
}
}
voidCGraph::PaiXu()
{
//inttemp=0;
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
for(inti=0;i<5;i++)
good[i]=0;
for(i=0;inum;i++)//对数据进行判断
{
if(pDoc->score[i]>=90&&pDoc->score[i]<=100)
good[0]++;//优秀的人数
路漫漫其修远兮,吾将上下而求索-百度文库
2525
else
{
if(pDoc->score[i]>=80)
good[1]++;//良好的人数
else
{
if(pDoc->score[i]>=70)
good[2]++;//中等的人数
else
{
if(pDoc->score[i]>=60)
good[3]++;//及格的人数
else
{
if(pDoc->score[i]>0&&pDoc->score[i]<60)
good[4]++;//不及格的人数
}
}
}
}
}
}
voidCGraph::DrawPie(CDC*pDC)
{
doublepie=3.1415926;//定义圆周率的值
CBrushbrush;//定义画刷
CPenpen;//定义画笔
CPointfpoint;//定义画弧的起点
CPointlpoint;//定义画弧的终点
CPointmpoint;//椭圆圆心
structtagRECTrect;//矩形坐标点
intr=0;//椭圆的长半径
intsum=0;//等级之和
CStrings;//输出的字符串
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
toppoint.x=(int)(pDoc->c.x0-(pDoc->*0.2));
toppoint.y=pDoc->c.y0-(int)pDoc->;
bottompoint.x=(int)(pDoc->c.x0+(pDoc->*1.2));
bottompoint.y=pDoc->c.y0;
r=(int)(bottompoint.y-toppoint.y)/2;
//矩形坐标点的初始化
路漫漫其修远兮,吾将上下而求索-百度文库
2626
=bottompoint.y;
=toppoint.x;
=bottompoint.x;
=toppoint.y;
//椭圆原点初始化
mpoint.x=(bottompoint.x+toppoint.x)/2;
mpoint.y=(bottompoint.y+toppoint.y)/2;;
//判断是否读入数据
if(pDoc->score[0]==NULL)
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
fpoint.x=bottompoint.x;//初始化起点
fpoint.y=mpoint.y;
for(inti=0;i<5;i++)//画饼状图
{
switch(i)
{
case0:s="优秀";
break;
case1:s="良好";
break;
case2:s="中等";
break;
case3:s="及格";
break;
case4:s="挂科";
break;
}
pDC->TextOut(toppoint.x+80*i-40,toppoint.y-30,s);
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Rectangle(toppoint.x+80*i,toppoint.y-30,toppoint.x+80*i+20,toppoint.y-15);
Object();//刷新颜色
if(good[i]>0)
{
sum+=good[i];
路漫漫其修远兮,吾将上下而求索-百度文库
2727
lpoint.x=mpoint.x+(int)(r*cos(2*pie*sum/pDoc->num));//初始化终点
lpoint.y=mpoint.y-(int)(r*sin(2*pie*sum/pDoc->num));
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Pie(toppoint.x,toppoint.y+10,bottompoint.x,bottompoint.y+10,fpoint.x,fpoint.y+10,lp
oint.x,lpoint.y+10);
//pDC->Pie(&rect,fpoint,lpoint);
Object();//刷新颜色
fpoint=lpoint;//把第一个的终点作为下一次画饼的起点
}
}
for(i=0;i<5;i++)
{
if(good[i]>0)
{
sum+=good[i];
lpoint.x=mpoint.x+(int)(r*cos(2*pie*sum/pDoc->num));//初始化终点
lpoint.y=mpoint.y-(int)(r*sin(2*pie*sum/pDoc->num));
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
//pDC->Pie(&rect,fpoint,lpoint);
//
pDC->Pie(toppoint.x,toppoint.y+10,bottompoint.x,bottompoint.y+10,fpoint.x,fpoint.y+10,lp
oint.x,lpoint.y+10);
pDC->Pie(&rect,fpoint,lpoint);
Object();//刷新颜色
fpoint=lpoint;//把第一个的终点作为下一次画饼的起点
}
}
}
}
voidCGraph::DrawQuXian(CDC*pDC)
{
inttemp=0;
inth=0;
floatz=0;
CPenpen;//定义画笔
CBrushbrush;
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
路漫漫其修远兮,吾将上下而求索-百度文库
2828
if(pDoc->score[0]==NULL)//判断是否读入了数据
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
for(inti=0;inum-1;)
{
h=(int)((pDoc->*9)/(pDoc->num*10));
z=(pDoc->*9)/1000;
Object();//清除画笔颜色
Pen(PS_SOLID,2,23456*(i+1));//创建画笔
pDC->SelectObject(&pen);//选择画笔
pDC->Ellipse(((i+1)*h+pDoc->c.x0)-2,(pDoc->c.y0-(int)(pDoc->score[i]*z))-2,(pDoc->c.x0+(i+1
)*h)+2,(pDoc->c.y0-(int)(pDoc->score[i]*z))+2);
pDC->MoveTo((i+1)*h+pDoc->c.x0,pDoc->c.y0-(int)(pDoc->score[i]*z));//画线
i++;
pDC->LineTo((i+1)*h+pDoc->c.x0,pDoc->c.y0-(int)(pDoc->score[i]*z));
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Ellipse(((i+1)*h+pDoc->c.x0)-2,(pDoc->c.y0-(int)(pDoc->score[i]*z))-2,(pDoc->c.x0+(i+1
)*h)+2,(pDoc->c.y0-(int)(pDoc->score[i]*z))+2);
Object();//刷新颜色
}
}
}
voidCGraph::DrawZhuZhuang(CDC*pDC)
{
//intFlag=1;
CPenpen;//定义画笔
CBrushbrush;//定义画刷
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
if(pDoc->score[0]==NULL)//判断是否读入了数据
::AfxMessageBox("数据还未读取,请先读取数据!");
else
{
intt;
floatz;
t=(int)((pDoc->*9)/(pDoc->num*10));
路漫漫其修远兮,吾将上下而求索-百度文库
2929
z=(pDoc->*9)/1000;
for(inti=0;inum;i++)
{
Object();//清除画笔颜色
Pen(PS_SOLID,1,2567*(i+1));//创建画笔
pDC->SelectObject(&pen);//选择画笔
SolidBrush(25555*(i+1));//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Rectangle((i+1)*t+pDoc->c.x0-4,(int)(pDoc->c.y0-pDoc->score[i]*z),(i+1)*t+pDoc->c.x0
+4,pDoc->c.y0);
Object();//刷新颜色
}
}
}
#if!defined(AFX_DLG_H__2E54A29F_A273_4A6B_B518_5BBB1A395403__INCLUDED_)
#defineAFX_DLG_H__2E54A29F_A273_4A6B_B518_5BBB1A395403__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
//Dlg.h:headerfile
//
/////////////////////////////////////////////////////////////////////////////
//CDlgdialog
classCDlg:publicCDialog
{
//Construction
public:
CDlg(CWnd*pParent=NULL);//standardconstructor
//DialogData
//{{AFX_DATA(CDlg)
enum{IDD=IDD_COORDINATE};
CStringm_xname;
CStringm_yname;
CStringm_xmax;
CStringm_ymax;
//}}AFX_DATA
路漫漫其修远兮,吾将上下而求索-百度文库
3030
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//Generatedmessagemapfunctions
//{{AFX_MSG(CDlg)
afx_msgvoidOnEnter();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!defined(AFX_DLG_H__2E54A29F_A273_4A6B_B518_5BBB1A395403__INCLUDED_)
//:implementationfile
//
#include"stdafx.h"
#include"GraphDraw.h"
#include"Dlg.h"
#include"mainfrm.h"
#include"graphdrawdoc.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
externCGraphDrawApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CDlgdialog
CDlg::CDlg(CWnd*pParent/*=NULL*/)
:CDialog(CDlg::IDD,pParent)
路漫漫其修远兮,吾将上下而求索-百度文库
3131
{
//{{AFX_DATA_INIT(CDlg)
m_xname=_T("X");
m_yname=_T("Y");
m_xmax=_T("100");
m_ymax=_T("100");
//}}AFX_DATA_INIT
}
voidCDlg::DoDataExchange(CDataExchange*pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg)
DDX_Text(pDX,IDC_EDIT1,m_xname);
DDX_Text(pDX,IDC_EDIT2,m_yname);
DDX_Text(pDX,IDC_EDIT3,m_xmax);
DDX_Text(pDX,IDC_EDIT4,m_ymax);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg,CDialog)
//{{AFX_MSG_MAP(CDlg)
ON_BN_CLICKED(IDC_ENTER,OnEnter)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CDlgmessagehandlers
voidCDlg::OnEnter()
{
//TODO:Addyourcontrolnotificationhandlercodehere
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
this->UpdateData(TRUE);
pDoc->=m_xmax;//赋值
pDoc->=m_xname;
pDoc->=m_ymax;
pDoc->=m_yname;
this->OnOK();
路漫漫其修远兮,吾将上下而求索-百度文库
3232
}
//Coordinate.h:interfacefortheCCoordinateclass.
//
//////////////////////////////////////////////////////////////////////
#if!defined(AFX_COORDINATE_H__3A908C95_5028_41F7_A086_BCCB1E57103F__INCLUDED_)
#defineAFX_COORDINATE_H__3A908C95_5028_41F7_A086_BCCB1E57103F__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
classCCoordinate
{
public:
floatwide;
floatlength;
CCoordinate();
voidDraw(CDC*pDC);//画坐标系
CStringxname;//横轴名称
CStringyname;//纵轴名称
CStringxmax;//横轴最大值
CStringymax;//纵轴最大值
virtual~CCoordinate();
intx0;//定义原点横坐标
inty0;//定义原点纵坐标
};
#endif
//!defined(AFX_COORDINATE_H__3A908C95_5028_41F7_A086_BCCB1E57103F__INCLUDED_)
//:implementationoftheCCoordinateclass.
//
//////////////////////////////////////////////////////////////////////
#include"stdafx.h"
#include"GraphDraw.h"
#include"Coordinate.h"
路漫漫其修远兮,吾将上下而求索-百度文库
3333
#include"mainfrm.h"
#include"graphdrawdoc.h"
#ifdef_DEBUG
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#definenewDEBUG_NEW
#endif
externCGraphDrawApptheApp;
//////////////////////////////////////////////////////////////////////
//Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCoordinate::CCoordinate()
{
x0=250;//初始化
y0=350;
xname="";
yname="";
xmax="";
ymax="";
length=250;
wide=100;
}
CCoordinate::~CCoordinate()
{
}
voidCCoordinate::Draw(CDC*pDC)//画坐标系
{
CPenpen;//定义画笔
CBrushbrush;//定义画刷
CStrings="";
CMainFrame*pFrame=(CMainFrame*)nWnd();
CGraphDrawDoc*pDoc=(CGraphDrawDoc*)pFrame->GetActiveDocument();
Pen(PS_SOLID,1,234567);//创建画笔
pDC->SelectObject(&pen);//选择画笔
if(xname!=""&&yname!=""&&xmax!=""&&ymax!="")
{
pDC->MoveTo(x0,y0);
pDC->LineTo(x0,(int)(y0-length));//画Y轴
pDC->MoveTo(x0,y0);
pDC->LineTo((int)(x0+length),y0);//画X轴
pDC->MoveTo(x0,(int)(y0-length));//画坐标轴箭头
路漫漫其修远兮,吾将上下而求索-百度文库
3434
pDC->LineTo(x0-8,(int)(y0-length+8));//
pDC->MoveTo(x0,(int)(y0-length));//
pDC->LineTo(x0+8,(int)(y0-length+8));//
pDC->MoveTo((int)(x0+length),y0);//
pDC->LineTo((int)(x0+length)-8,y0-8);//
pDC->MoveTo((int)(x0+length),y0);//
pDC->LineTo((int)(x0+length)-8,y0+8);//
pDC->Ellipse(x0-3,y0-3,x0+3,y0+3);//画坐标原点
Object();//清除画笔颜色
SolidBrush(255);//创建画刷颜色
pDC->SelectObject(&brush);//选择画刷
pDC->Ellipse(x0-4,y0-4,x0+4,y0+4);
Object();//刷新颜色
s="0";//输出原点
pDC->TextOut(x0-10,y0+10,s);
s=xname;//输出横轴名称
pDC->TextOut((int)(x0+length)+10,y0-20,s);
s=yname;//输出纵轴名称
pDC->TextOut(x0+15,(int)(y0-length)-40,s);
s=xmax;//输出横轴最大值
pDC->TextOut((int)(x0+length)+10,y0+10,s);
s=ymax;//输出纵轴最大值
pDC->TextOut(x0-30,(int)(y0-length)-20,s);
wide=length*9/100;
for(inti=1;i<11;i++)//输出纵轴单位坐标
{
("%d",10*i);
pDC->TextOut(x0-30,(int)(y0-wide*i)-10,s);
pDC->MoveTo(x0,(int)(y0-wide*i));
pDC->LineTo(x0+5,(int)(y0-wide*i));
}
wide=(pDoc->*9)/(pDoc->num*10);
for(i=1;inum;i++)//输出横轴单位坐标
{
("%d",i);
pDC->TextOut((int)(x0+(wide*i))-5,y0+10,s);
pDC->MoveTo((int)(x0+(wide*i)),y0);
pDC->LineTo((int)(x0+(wide*i)),y0-5);
}
("%s","横轴坐标的数字代表第几个学生的成绩");//对横轴单位坐标的说明
pDC->TextOut(x0,y0+50,s);
路漫漫其修远兮,吾将上下而求索-百度文库
3535
}
else
::AfxMessageBox("坐标系还未建立,请先建立坐标系!");
}
implement_dyncreate