}
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { }
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
BOOL bNameValid; CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty()) { }
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
void CTwoDlg::OnSysCommand(UINT nID, LPARAM lParam) { }
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CTwoDlg::OnPaint()
if ((nID & 0xFFF0) == IDM_ABOUTBOX) { } else { }
CDialogEx::OnSysCommand(nID, lParam); CAboutDlg dlgAbout; dlgAbout.DoModal();
26
{ }
// The system calls this function to obtain the cursor to display while the user drags // the minimized window.
HCURSOR CTwoDlg::OnQueryDragIcon() { }
void CTwoDlg::OnEnChangeEdit1() { }
// TODO: Add your control notification handler code here // TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialogEx::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. return static_cast
CDialogEx::OnPaint(); // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
// Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;
SendMessage(WM_ICONERASEBKGND, reinterpret_cast
CPaintDC dc(this); // device context for painting
27
void CTwoDlg::OnBnClickedButton4() {
// TODO: 在此添加控件通知处理程序代码 CString mStr;
GetDlgItem(IDC_EDIT1)->GetWindowTextW(mStr); int n;
n = parseInt(mStr); double e = 1.0; int i = 0; while (i double a, b, h; a = 0, b = 6, h = b - a; double T1, T2; T1 = h*(fun(a) + fun(b)) / 2; double s, x; CDC *p = GetDC(); while (true) { s = 0; x = a + h / 2; while (true) { bool flag = fun(x) >0 ? 1 : 0; for (int i = 300 - fun(x) * 100;; ) { } //p->MoveTo(100 + 50 * x, 300); //p->LineTo(100 + 50 * x, 300 - fun(x) * 100); s += fun(x); x += h; if (x >= b) break; p->MoveTo(100 + 50 * x, i); i = flag ? i + 1 : i - 1; if ((flag&&i > 300) || (!flag&&i < 300)) { } Sleep(10); p->LineTo(100 + 50 * x, i); break; e *= 0.1; i++; 28 } } } T2 = T1 / 2 + h*s / 2; if (fabs(T2 - T1) < e) break; h /= 2; T1 = T2; CString ms; ms.Format(_T(\), T2); p->TextOutW(200, 50, _T(\变长分步积分算法求定积分的解为:\)); p->TextOutW(250, 70, ms); ReleaseDC(p); void CTwoDlg::OnBnClickedButton5() { } void CTwoDlg::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 CDC *p = GetDC(); p->SetBkColor(RGB(240, 240, 240)); //绘制X轴 p->MoveTo(50, 300); p->LineTo(450, 300); p->MoveTo(445, 295); p->LineTo(450, 300); p->MoveTo(445, 305); p->LineTo(450, 300); p->TextOutW(102, 302, _T(\)); p->TextOutW(450, 300, _T(\轴\)); for (int i = 1; i <= 6; i++) { CString ms; ms.Format(_T(\), i + 0.0); p->TextOutW(100 + 50 * i, 302, ms); p->MoveTo(100 + 50 * i, 300); // TODO: 在此添加控件通知处理程序代码 CDC *pDC = GetDC(); CRect rc(5, 5, 500, 400); pDC->FillSolidRect(&rc, RGB(240, 240, 240)); ReleaseDC(pDC); 29 }a } p->LineTo(100 + 50 * i, 295); //绘制Y轴 p->MoveTo(100, 350); p->LineTo(100, 100); p->MoveTo(95, 105); p->LineTo(100, 100); p->MoveTo(105, 105); p->LineTo(100, 100); p->TextOutW(100, 80, _T(\轴\)); for (int i = 1; i <= 3; i++) { } ReleaseDC(p); CString ms; ms.Format(_T(\), 1.0 / 2 * i); p->TextOutW(80, 300 - 50 * i, ms); p->MoveTo(100, 300 - 50 * i); p->LineTo(105, 300 - 50 * i); void CTwoDlg::OnBnClickedButton2() { } void CTwoDlg::OnBnClickedButton3() { // TODO: 在此添加控件通知处理程序代码 CDC *p; p = GetDC(); int i = 100; while (true) { } ReleaseDC(p); p->MoveTo(i, 300 - 100 * fun((i - 100) / 50.0)); i++; if (i == 400 + 1) break; Sleep(10); p->LineTo(i, 300 - 100 * fun((i - 100) / 50.0)); 30