Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Index Visual C++ and MFC Fundamentals



  1. Implement it as follows:


// MOIDefTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MOIDefTest.h"
#include "MOIDefTestDlg.h"
#include ".\moideftestdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

double MOIRectX(double b, double h);

// CMOIDefTestDlg dialog

CMOIDefTestDlg::CMOIDefTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMOIDefTestDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

...


void CMOIDefTestDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
double MOI = MOIRectX(3.25, 2.15);
char Sentence[40];

sprintf(Sentence, "Moment of Inertia: %.3f", MOI);
MessageBox(Sentence);
}


  1. Test the application

  2. Close the dialog box and return to MSVC

  3. To use the header file, return to Windows Explorer or My Computer

  4. Locate the folder that contains the MomentInertia project and copy the
    MomentOfInertia.h header file

  5. Paste the MomentOfInertia.h file in the folder that contains the current project

  6. Change the above file as follows:


#include "stdafx.h"
Free download pdf