Triangle Area
// XxxxDlg. cpp: implementation file // # include "stdafx. h "# include" xxxx. h "# include" xxxxDlg. h "# include" Cmath "# ifdef _ DEBUG # define new DEBUG_NEW # undef THIS_FILEstatic char THIS_FILE [] = _ FILE __; # endif ////////////////////////////////////// //////////////////////////////////////// /CAboutDlg dialog used for App Aboutclass CAboutDlg: public CDialog {public: CAboutDlg (); // Dialog Data // {AFX_DATA (CAbout Dlg) enum {IDD = IDD_ABOUTBOX}; //} AFX_DATA // ClassWizard generated virtual function overrides // {AFX_VIRTUAL (CAboutDlg) protected: virtual void DoDataExchange (CDataExchange * pDX ); // DDX/DDV support //} AFX_VIRTUAL // Implementationprotected: // {AFX_MSG (CAboutDlg) //} AFX_MSGDECLARE_MESSAGE_MAP ()}; CAboutDlg: CAboutDlg (): CDialog (CAboutDlg: IDD) {// {AFX_DATA_INIT (CAboutDlg) //} AFX_DATA_INIT} void CAbo UtDlg: DoDataExchange (CDataExchange * pDX) {CDialog: DoDataExchange (pDX); // {AFX_DATA_MAP (CAboutDlg) //} AFX_DATA_MAP} Export (CAboutDlg, CDialog) // {AFX_MSG_MAP (CAboutDlg) // No message handlers //} AFX_MSG_MAPEND_MESSAGE_MAP () //////////////////////////////////////// /// // CXxxxDlg dialogCXxxxDlg:: CXxxxDlg (CWnd * pParent/* = NULL */): CDialog (CXxxxDlg: IDD, pPare Nt) {// {AFX_DATA_INIT (CXxxxDlg) m_a = 0.0; m_ B = 0.0; m_c = 0.0; m_s = 0.0; ///} AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in response = AfxGetApp ()-> LoadIcon (IDR_MAINFRAME);} void exchange: DoDataExchange (CDataExchange * pDX) {CDialog: DoDataExchange (pDX); // {AFX_DATA_MAP (CXxxxDlg) 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_s); //} AFX_DATA_MAP} values (CXxxxDlg, CDialog) // {AFX_MSG_MAP (CXxxxDlg) values () ON_WM_PAINT () ON_WM_QUERYDRAGICON () ON_BN_CLICKED (IDC_BUTTON1, OnButton1) //} AFX_MSG_MAPEND_MESSAGE_MAP () //////////////////////////////////////// /// // CXxxxDlg message handlersBOOL CXxxxDlg:: OnInitDialog () {CDialog: OnInitDialog (); // Add" Bout... "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) {CString strAboutMenu; strAboutMenu. LoadString (IDS_ABOUTBOX); 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 dialogSetIcon (m_hIcon, TRUE); // Set big iconSetIcon (m_hIcon, FALSE ); // Set small icon // TODO: Add extra initialization herereturn TRUE; // return TRUE unless you set the focus to a control} void CXxxxDlg: 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 CXxxxDlg: OnPaint () {if (IsIconic () {CPaintDC dc (this); // device context for paintingSendMessage (WM_ICONERASEBKGND, (WPARAM) dc. getSafeHdc (), 0); // Center icon in client rectangleint 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 icondc. drawIcon (x, y, m_hIcon);} else {CDialog: OnPaint ();}} // The system callthis to obtain the cursor to display while the user drags // the minimized window. HCURSOR CXxxxDlg: OnQueryDragIcon () {return (HCURSOR) m_hIcon;} void CXxxxDlg: OnButton1 () {// TODO: Add your control notification handler code hereUpdateData (); double m_l; if (m_a + m_ B) <m_c | (m_a + m_c) <m_ B | (m_c + m_ B) <m_a) MessageBox ("Triangle does not exist "); else {m_l = (m_a + m_ B + m_c) * 1/2; m_s = sqrt (m_l * (m_l-m_a) * (m_l-m_ B) * (m_l-m_c); UpdateData (FALSE );}}