第15周实验报告任务 1
2012-05-28 20:42
411 查看
/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:为应用程序增加求周长的功能
* 作 者: 陶锋
* 完成日期: 2012 年 05 月 28 日
* 版 本 号: V1.0
* 对任务及求解方法的描述部分
* 输入描述:
* 问题描述:
* 程序输出:
* 程序头部的注释结束
*/
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:为应用程序增加求周长的功能
* 作 者: 陶锋
* 完成日期: 2012 年 05 月 28 日
* 版 本 号: V1.0
* 对任务及求解方法的描述部分
* 输入描述:
* 问题描述:
* 程序输出:
* 程序头部的注释结束
*/
// triangleDlg.cpp : implementation file // #include "stdafx.h" #include "triangle.h" #include "triangleDlg.h" #include "MyTriangle.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CtriangleDlg dialog CtriangleDlg::CtriangleDlg(CWnd* pParent /*=NULL*/) : CDialog(CtriangleDlg::IDD, pParent) , m_a(0) , m_b(0) , m_c(0) , m_area(0) , m_perimeter(0) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CtriangleDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT1, m_a); DDX_Text(pDX, IDC_EDIT2, m_b); DDX_Text(pDX, IDC_EDIT3, m_c); DDX_Text(pDX, IDC_EDIT4, m_area); DDX_Text(pDX, IDC_EDIT5, m_perimeter); } BEGIN_MESSAGE_MAP(CtriangleDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON1, &CtriangleDlg::OnBnClickedButton1) ON_BN_CLICKED(IDC_BUTTON3, &CtriangleDlg::OnBnClickedButton3) ON_BN_CLICKED(IDC_BUTTON4, &CtriangleDlg::OnBnClickedButton4) END_MESSAGE_MAP() // CtriangleDlg message handlers BOOL CtriangleDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { 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); } } // 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 // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CtriangleDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, 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 CtriangleDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 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; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CtriangleDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CtriangleDlg::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 UpdateData(); //将把界面上各控件输入的值“捕获”到与之关联的变量中 Triangle t1(m_a,m_b,m_c); //定义三角形对象 m_area=t1.area(); //求面积 UpdateData(FALSE); //用m_area的值更新界面上对应的控件的值并实现显示 } void CtriangleDlg::OnBnClickedButton4() { // TODO: Add your control notification handler code here UpdateData(); //将把界面上各控件输入的值“捕获”到与之关联的变量中 Triangle t1(m_a,m_b,m_c); //定义三角形对象 m_perimeter=t1.perimeter(); //求面积 UpdateData(FALSE); //用m_area的值更新界面上对应的控件的值并实现显示 }
相关文章推荐
- 第15周实验报告任务2
- 第15周实验报告任务1
- 第15周实验报告任务3
- 《C++第九周实验报告2-1》---接第8周任务2,定义Time类中的<<和>>运算符重载,实现时间的输入输出
- 《第十周实验报告任务1》
- C++程序设计实验报告(六十六)---第十二周任务二
- 第12周实验报告任务4
- 13周实验报告(任务4)
- 第二学期第二周实验报告任务一
- C++程序设计实验报告(七十四)---第十四周任务二
- 第14周实验报告任务1
- C++程序设计实验报告(三十二)---第三周任务二
- 第十五周实验报告(任务一)【窗口程序设计之三角形类】
- 第十五周实验报告任务1
- 第十八周实验报告(任务二)
- C++程序设计实验报告(七十九)---第十六周任务一
- C++程序设计实验报告(三十五)---第四周任务一
- C++程序设计实验报告(八十四) --- 第十七周任务一
- 第四周实验报告(任务3)
- 第四周实验报告(任务二)