Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Index Visual C++ and MFC Fundamentals



  1. Click Open

  2. Delete the TODO line on the dialog box. Add a new Button. Change its Caption to
    MOI Test

  3. Double-click the new button to initiate its BN_CLICKED message

  4. 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];
Free download pdf