?? ht.cpp
字號:
// HT.cpp : implementation file
//
#include "stdafx.h"
#include "JSQ.h"
#include "HT.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// HT dialog
HT::HT(CWnd* pParent /*=NULL*/)
: CDialog(HT::IDD, pParent)
{
//{{AFX_DATA_INIT(HT)
// NOTE: the ClassWizard will add member initialization here
m_edit_x1 = 0.0;//初始畫圖左區間
m_edit_x2 = 0.0;//初始畫圖右區間
m_s = _T("");
//}}AFX_DATA_INIT
}
void HT::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(HT)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Text(pDX, IDC_EDIT_X1, m_edit_x1);
DDX_Text(pDX, IDC_EDIT_X2, m_edit_x2);
DDX_Text(pDX, IDC_EDIT1, m_s);
// // DDX_Text(pDX, IDC_A_EDIT2, m_lq);
/// // DDX_Text(pDX, IDC_B_EDIT4, m_rq);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(HT, CDialog)
//{{AFX_MSG_MAP(HT)
// NOTE: the ClassWizard will add message map macros here
ON_BN_CLICKED(IDC_FFRUN, OnFfrun)
//// ON_WM_PAINT()
ON_BN_CLICKED(IDC_CLEAR, OnClear)
ON_BN_CLICKED(IDCANCEL, OnCancel)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// HT message handlers
double HT::f(double x)
{
double f=sin(x)/x;
return f;
}
void HT::OnFfrun()
{
// TODO: Add your control notification handler code here
// bool w;
int xmax=530;//
int xmin=30;
int ymax=250;
int ymin=30;
double h=0.01;
min=99999,max=-99999;//draw中定義
UpdateData(true);
CClientDC c(this);
CPen draw;
draw.CreatePen(0,1,RGB(0,0,255));
c.SelectObject(draw);
//繪制橫縱軸
c.MoveTo((xmax+xmin)/2,ymin);
c.LineTo((xmax+xmin)/2,ymax);
c.MoveTo(xmin,(ymax+ymin)/2);
c.LineTo(xmax,(ymax+ymin)/2);
XB=(xmax-xmin)/(m_edit_x2-m_edit_x1);
double t=m_edit_x1;
while(t+0.01<m_edit_x2)
{
double j;
j=f(t+h);
if(j<min)
{
min=j;
}
if(j>max)
{
max=j;
}
t=t+h;
}
YB=(ymax-ymin)/(max-min);
//繪制坐標
CString te1,te2;
te1.Format("%3.2f",m_edit_x1);
te2.Format("%3.2f",(min+max)/2);
c.TextOut(50,130,"("+te1+","+te2+")");
te1.Format("%3.2f",m_edit_x2);
c.TextOut(350,130,"("+te1+","+te2+")");
te1.Format("%3.2f",max);
te2.Format("%3.2f",(m_edit_x1+m_edit_x2)/2);
c.TextOut(240,30,"("+te2+","+te1+")");
te1.Format("%3.2f",min);
c.TextOut(240,200,"("+te2+","+te1+")");
te1.Format("%3.2f",(max+min)/2);
c.TextOut(200,130,"("+te2+","+te1+")");
//c.TextOut(200,130,"("+te2+","+te1+")");
double t1=m_edit_x1;
while(xmin+1<xmax)
{
c.MoveTo((int)(xmin),(int)(ymax-(f(t1)-min)*YB));
c.LineTo((int)(xmin+1),(int)(ymax-(f(t1+1/XB)-min)*YB));
xmin++;
t1=t1+1/XB;
}
// w=false;
//UpdateData(FALSE);
}
void HT::OnClear()
{
// TODO: Add your control notification handler code here
CClientDC s(this);
s.FillSolidRect(20,20,535,250,RGB(255,255,255));
//((CListBox*)GetDlgItem(IDC_STATIC))->ResetContent();
/*
// TODO: Add your control notification handler code here
CDC *pDC;
pDC=GetDC();
////////////////////
CRect rect;
GetClientRect(&rect);
/////////////////
pDC->SelectStockObject(WHITE_BRUSH);
pDC->Rectangle(rect.left,rect.top,rect.right-1,rect.bottom-90);
pDC->MoveTo(rect.left,(rect.top-rect.bottom+75)/2+rect.bottom-90);
pDC->LineTo(rect.right-1,(rect.top-rect.bottom+75)/2+rect.bottom-90);
*/
}
void HT::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
UpdateData(TRUE);
CDialog::OnMouseMove(nFlags, point);
CString tem;
tem.Format("%d,%d",point.x,point.y);
m_s=tem;
UpdateData(FALSE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -