Index Visual C++ and MFC Fundamentals
- 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);
}
- Test the application
- Close the dialog box and return to MSVC
- To use the header file, return to Windows Explorer or My Computer
- Locate the folder that contains the MomentInertia project and copy the
MomentOfInertia.h header file - Paste the MomentOfInertia.h file in the folder that contains the current project
- Change the above file as follows:
#include "stdafx.h"