void CCOMTOOLDlg: : OnButtonXiantu ()
{
CPaintDC dc (this);
CRect the rect.
GetDlgItem (IDC_STATIC_PAINT) - & gt; GetClientRect (the rect);
The CWnd * pWnd=GetDlgItem (IDC_STATIC_PAINT);
The CDC * pDC=pWnd - & gt; GetDC ();
PWnd - & gt; Invalidate ().
PWnd - & gt; UpdateWindow ();
PDC - & gt; SetMapMode (MM_ANISOTROPIC);
PDC - & gt; SetViewportOrg (0, 0);
PDC - & gt; SetViewportExt (the rect. Right, the rect. Bottom);
PDC - & gt; SetWindowOrg (0, 0);
PDC - & gt; SetWindowExt (580310);
Double w;
Cstrings strcai;
GetDlgItemText (IDC_EDIT_CAIYANG strcai);
If (strcai=="")
AfxMessageBox (" please enter the sampling interval!" );
The else
W=atof (strcai);
//double w=0.5;//set the sampling rate
Double n=540.0/380.0;
Double m=270.0/6.0;
Int ns=int (360.0/w);
The rect. Width ();
The rect. Height ();
Alternative nxLength//use the rect. Width (), the rect. Height () to replace nyLength
Int nxLength=the rect. Width ();
Int nyLength=the rect. Height ();
Int nxDivisionNumber=18;
Int nyDivisionNumber=5;
Int nMeshLength;
CString str;
Int t;
PDC - & gt; A Rectangle (0, 0, nxLength nyLength);
CPen * pPenRed=new CPen;//create a brush object
PPenRed - & gt; CreatePen (PS_SOLID, 1, RGB (0, 255));//red brush
CPen * pPenGreen=new CPen;//create a brush object
PPenGreen - & gt; CreatePen (PS_SOLID, 1, RGB (0255, 0));//green brush
CPen * pPenBlue=new CPen;//create a brush object
PPenBlue - & gt; CreatePen (PS_DOT, 1, RGB (0,0,255));//blue brush
CPen * pPenBlack=new CPen;//create a brush object
PPenBlack - & gt; CreatePen (PS_SOLID, 1, RGB (0, 0));//black brush
//selected black brush, and save the current brush
The CGdiObject * pOldPen=pDC - & gt; SelectObject (pPenBlack);
PDC - & gt; MoveTo (30, 10);//draw the axis
PDC - & gt; LineTo (30, nyLength - 30);//vertical axis, the (30, nyLength - 30) origin of coordinates is customer
PDC - & gt; LineTo (nxLength - 10, nyLength - 30);//horizontal axis
//the abscissa arrow
PDC - & gt; MoveTo (nyLength, nxLength - 10-10-30-3);
PDC - & gt; LineTo (nxLength - 10, nyLength - 30);
PDC - & gt; LineTo (nyLength, nxLength - 10-10-30 + 3);
PDC - & gt; LineTo (nyLength, nxLength - 10-10-30-3);
//the vertical arrow
PDC - & gt; MoveTo (27, 20);
PDC - & gt; LineTo (30, 10);
PDC - & gt; The LineTo (33, 20);
PDC - & gt; The LineTo (27, 20);
//abscissa number
NMeshLength=(nxLength - 40)/(nxDivisionNumber + 1);
For (t=0; tSTR. The Format (" % d ", t * 20);
PDC - & gt; TextOut ((27 + t * nMeshLength), nyLength - 27, STR);
}
//abscissa logo
STR. The Format (" Angle ");
PDC - & gt; TextOut (nxLength - 33, nyLength - 27, STR);
//ordinate number
NMeshLength=(nyLength - 40)/(nyDivisionNumber + 1);
For (t=0; tSTR. The Format (" % d ", t);
PDC - & gt; TextOut (3, nyLength - 40 - t * nMeshLength, STR);
}
//ordinate logo
STR. The Format (" voltage value ");
PDC - & gt; TextOut (1, 3, STR);
//grid lines
PDC - & gt; SelectObject (pPenBlue);
NMeshLength=(nxLength - 40)/(nxDivisionNumber + 1);
For (t=1; tPDC - & gt; MoveTo (30 + t * nMeshLength nyLength - 30);
PDC - & gt; LineTo (30 + t * nMeshLength, 10);
}
NMeshLength=(nyLength - 40)/(nyDivisionNumber + 1);
For (t=1; tPDC - & gt; MoveTo (30, nyLength - 30 - t * nMeshLength);
PDC - & gt; LineTo (nxLength - 10, nyLength - 30 - t * nMeshLength);
}
//TODO: Add your the control notification handler code here
//cstrings stredit;
//GetDlgItem (IDC_EDIT_OPEN) - & gt; GetWindowText (stredit);
Cstrings strdata1 strdata2, strdata3 strdata4;//used to temporarily store the interception of column values
Int index;
int i=0;
Int line=0;//record line number
Double * data1;
Data1=new double (ns);//store the first column the results
Double * data2;
Data2=new double (ns);//store the second column the results
Double * data3;
Data3=new double (ns);//store the third column the results
Double * data4;
Data4=new double (ns);//store the fourth column results
//read a line of content in strLine
//int nLineCount=m_Receive. GetLineCount ();
Int nLineCount=m_open. GetLineCount ();//get edit control the number of rows
Cstrings strText linebuf;
//Dump every line of the text of the edit control.
for (i=1; I & lt; NLineCount; I++)
{
//the length of the line I:
//int len=m_Receive. LineLength (m_Receive. LineIndex (I));
Int len=m_open. LineLength (m_open LineIndex (I));//LineLength edit control the length of the boc, LineIndex gain in a multiline edit control line character index
//m_Receive GetLine (I, strText GetBuffer (len), len);
M_open. GetLine (I, strText. GetBuffer (len), len);//Getline gain edit control line
StrText. ReleaseBuffer (len);//ReleaseBuffer release GetBuffer allocation of dynamic memory
//linebuf. The Format (_T (" line % d: '% s' \ n "), I, strText);
Linebuf. The Format (_T (" % s \ n "), strText);
//AfxMessageBox (linebuf);
//AFXDUMP (linebuf);//output data row
//to get to the first TAB key index
The index=strText. FindOneOf (TEXT (" "));
//in the first column data
Strdata1=strText. Left (8);
//after take to delete the content
StrText. Delete (0, index);
//remove space
StrText. TrimLeft ();
The index=strText. FindOneOf (TEXT (" "));
//after take to delete the content
StrText. Delete (0, index);
//remove space
StrText. TrimLeft ();
//the second column data
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull