Index Visual C++ and MFC Fundamentals
- Click Open
- Delete the TODO line on the dialog box. Add a new Button. Change its Caption to
MOI Test - Double-click the new button to initiate its BN_CLICKED message
- Implement it as follows:
// MOITestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MOITest.h"
#include "MOITestDlg.h"
#include ".\moitestdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Calculation of the moment of inertia
// Rectangle
extern "C" _declspec(dllimport)double MOIRectangle(double b, double h);
// Semi-Circle
extern "C" _declspec(dllimport)double MOISemiCircle(double r);
// Triangle
extern "C" _declspec(dllimport)double MOITriangle(double b, double h, int);
// CMOITestDlg dialog
CMOITestDlg::CMOITestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMOITestDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
...
void CMOITestDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
double MOI = MOIRectangle(3.25, 2.65);
char Sentence[40];