📄 zsfdlg.cpp
字号:
// ZSFDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ZSF.h"
#include "ZSFDlg.h"
#include "HL.h"
#include "Jd.h"
#include "Scl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
public:
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZSFDlg dialog
CZSFDlg::CZSFDlg(CWnd* pParent /*=NULL*/)
: CDialog(CZSFDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZSFDlg)
m_scl_x = 1.0f;
m_jdl_x = 1.0f;
m_hl_x = 1.0f;
m_sx1 = 0.0;
m_sy1 = 0.0;
m_sx2 = 0.0;
m_sy2 = 0.0;
m_sx3 = 0.0;
m_sy3 = 0.0;
m_sx4 = 0.0;
m_sy4 = 0.0;
m_sx5 = 0.0;
m_sy5 = 0.0;
m_sx6 = 0.0;
m_sy6 = 0.0;
m_sx7 = 0.0;
m_sy7 = 0.0;
m_hx1 = 0.0;
m_hy1 = 0.0;
m_hx2 = 0.0;
m_hy2 = 0.0;
m_hx3 = 0.0;
m_hy3 = 0.0;
m_hx4 = 0.0;
m_hy4 = 0.0;
m_hx5 = 0.0;
m_hy5 = 0.0;
m_hx6 = 0.0;
m_hy6 = 0.0;
m_hx7 = 0.0;
m_hy7 = 0.0;
m_jx1 = 0.0;
m_jy1 = 0.0;
m_jx2 = 0.0;
m_jy2 = 0.0;
m_jx3 = 0.0;
m_jy3 = 0.0;
m_jx4 = 0.0;
m_jy4 = 0.0;
m_jx5 = 0.0;
m_jy5 = 0.0;
m_jx6 = 0.0;
m_jy6 = 0.0;
m_jx7 = 0.0;
m_jy7 = 0.0;
m_hlzsh = 0.0;
m_sclzsh = 0.0;
m_jdlzshu = 0.0;
m_zdl = 0.0;
m_z33 = 1.0;
m_z32 = 1.0;
m_z31 = 1.0;
m_z3 = 0.0;
m_z23 = 1.0;
m_z22 = 1.0;
m_z21 = 1.0;
m_z2 = 0.0;
m_z13 = 1.0;
m_z12 = 1.0;
m_z11 = 1.0;
m_z1 = 0.0;
m_z_xs = 1.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZSFDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZSFDlg)
DDX_Text(pDX, IDC_EDIT_SCL_X, m_scl_x);
DDX_Text(pDX, IDC_EDIT_JDL_X, m_jdl_x);
DDX_Text(pDX, IDC_EDIT_HL_X, m_hl_x);
DDX_Text(pDX, IDC_EDIT_SCL_1, m_sx1);
DDX_Text(pDX, IDC_EDIT_SCL_11, m_sy1);
DDX_Text(pDX, IDC_EDIT_SCL_2, m_sx2);
DDX_Text(pDX, IDC_EDIT_SCL_22, m_sy2);
DDX_Text(pDX, IDC_EDIT_SCL_3, m_sx3);
DDX_Text(pDX, IDC_EDIT_SCL_33, m_sy3);
DDX_Text(pDX, IDC_EDIT_SCL_4, m_sx4);
DDX_Text(pDX, IDC_EDIT_SCL_44, m_sy4);
DDX_Text(pDX, IDC_EDIT_SCL_5, m_sx5);
DDX_Text(pDX, IDC_EDIT_SCL_55, m_sy5);
DDX_Text(pDX, IDC_EDIT_SCL_6, m_sx6);
DDX_Text(pDX, IDC_EDIT_SCL_66, m_sy6);
DDX_Text(pDX, IDC_EDIT_SCL_7, m_sx7);
DDX_Text(pDX, IDC_EDIT_SCL_77, m_sy7);
DDX_Text(pDX, IDC_EDIT_HL_1, m_hx1);
DDX_Text(pDX, IDC_EDIT_HL_11, m_hy1);
DDX_Text(pDX, IDC_EDIT_HL_2, m_hx2);
DDX_Text(pDX, IDC_EDIT_HL_22, m_hy2);
DDX_Text(pDX, IDC_EDIT_HL_3, m_hx3);
DDX_Text(pDX, IDC_EDIT_HL_33, m_hy3);
DDX_Text(pDX, IDC_EDIT_HL_4, m_hx4);
DDX_Text(pDX, IDC_EDIT_HL_44, m_hy4);
DDX_Text(pDX, IDC_EDIT_HL_5, m_hx5);
DDX_Text(pDX, IDC_EDIT_HL_55, m_hy5);
DDX_Text(pDX, IDC_EDIT_HL_6, m_hx6);
DDX_Text(pDX, IDC_EDIT_HL_66, m_hy6);
DDX_Text(pDX, IDC_EDIT_JDL_1, m_jx1);
DDX_Text(pDX, IDC_EDIT_JDL_11, m_jy1);
DDX_Text(pDX, IDC_EDIT_JDL_2, m_jx2);
DDX_Text(pDX, IDC_EDIT_JDL_22, m_jy2);
DDX_Text(pDX, IDC_EDIT_JDL_3, m_jx3);
DDX_Text(pDX, IDC_EDIT_JDL_33, m_jy3);
DDX_Text(pDX, IDC_EDIT_JDL_4, m_jx4);
DDX_Text(pDX, IDC_EDIT_JDL_44, m_jy4);
DDX_Text(pDX, IDC_EDIT_JDL_5, m_jx5);
DDX_Text(pDX, IDC_EDIT_JDL_55, m_jy5);
DDX_Text(pDX, IDC_EDIT_JDL_6, m_jx6);
DDX_Text(pDX, IDC_EDIT_JDL_66, m_jy6);
DDX_Text(pDX, IDC_EDIT_JDL_7, m_jx7);
DDX_Text(pDX, IDC_EDIT_JDL_77, m_jy7);
DDX_Text(pDX, IDC_EDIT_HLZS, m_hlzsh);
DDX_Text(pDX, IDC_EDIT_SCLZS, m_sclzsh);
DDX_Text(pDX, IDC_EDIT_JDLZS, m_jdlzshu);
DDX_Text(pDX, IDC_EDIT_ZHDLZH, m_zdl);
DDX_Text(pDX, IDC_EDIT_Z33, m_z33);
DDX_Text(pDX, IDC_EDIT_Z32, m_z32);
DDX_Text(pDX, IDC_EDIT_Z31, m_z31);
DDX_Text(pDX, IDC_EDIT_Z3, m_z3);
DDX_Text(pDX, IDC_EDIT_Z23, m_z23);
DDX_Text(pDX, IDC_EDIT_Z22, m_z22);
DDX_Text(pDX, IDC_EDIT_Z21, m_z21);
DDX_Text(pDX, IDC_EDIT_Z2, m_z2);
DDX_Text(pDX, IDC_EDIT_Z13, m_z13);
DDX_Text(pDX, IDC_EDIT_Z12, m_z12);
DDX_Text(pDX, IDC_EDIT_Z11, m_z11);
DDX_Text(pDX, IDC_EDIT_Z1, m_z1);
DDX_Text(pDX, IDC_EDIT_TZXSH, m_z_xs);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZSFDlg, CDialog)
//{{AFX_MSG_MAP(CZSFDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_HLQZ, OnButtonHlqz)
ON_BN_CLICKED(IDC_BUTTON_HLZSHU, OnButtonHlzshu)
ON_BN_CLICKED(IDC_BUTTON_SCLQZ, OnButtonSclqz)
ON_BN_CLICKED(IDC_BUTTON_JDLQZ, OnButtonJdlqz)
ON_BN_CLICKED(IDC_BUTTON_SCLZSHU, OnButtonSclzshu)
ON_BN_CLICKED(IDC_BUTTON_JDLZSHU, OnButtonJdlzshu)
ON_BN_CLICKED(IDC_BUTTON_ZDLQZ, OnButtonZdlqz)
ON_BN_CLICKED(IDC_BUTTON_JSZDLZSH, OnButtonJszdlzsh)
ON_EN_KILLFOCUS(IDC_EDIT_Z12, OnKillfocusEditZ12)
ON_EN_KILLFOCUS(IDC_EDIT_Z13, OnKillfocusEditZ13)
ON_EN_KILLFOCUS(IDC_EDIT_Z23, OnKillfocusEditZ23)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZSFDlg message handlers
BOOL CZSFDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." 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 dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CZSFDlg::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 CZSFDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int 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 icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZSFDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZSFDlg::OnButtonHlqz()
{
// TODO: Add your control notification handler code here
CHL hl;
hl.DoModal();
}
void CZSFDlg::OnButtonHlzshu()
{
// TODO: Add your control notification handler code here
UpdateData();
m_hlzsh=m_hl_x*pow(m_hx1,m_hy1)*pow(m_hx2,m_hy2)*pow(m_hx3,m_hy3)*pow(m_hx4,m_hy4)
*pow(m_hx5,m_hy5)*pow(m_hx6,m_hy6);
UpdateData(FALSE);
}
void CZSFDlg::OnButtonSclqz()
{
// TODO: Add your control notification handler code here
CSCL scl;
scl.DoModal();
}
void CZSFDlg::OnButtonJdlqz()
{
CJD jd;
jd.DoModal();
}
void CZSFDlg::OnButtonSclzshu() //计算生存力指数
{
UpdateData();
m_sclzsh=m_scl_x*pow(m_sx1,m_sy1)*pow(m_sx2,m_sy2)*pow(m_sx3,m_sy3)*pow(m_sx4,m_sy4)
*pow(m_sx5,m_sy5)*pow(m_sx6,m_sy6)*pow(m_sx7,m_sy7);
UpdateData(FALSE);
}
BOOL CZSFDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
extern double s1,s2,s3,s4,s5,s6,s7;
extern int status;
if (status==1)
{
m_hx1=s1;
m_hx2=s2;
m_hx3=s3;
m_hx4=s4;
m_hx5=s5;
m_hx6=s6;
status=0;
UpdateData(FALSE);
}
if (status==2)
{
m_jx1=s1;
m_jx2=s2;
m_jx3=s3;
m_jx4=s4;
m_jx5=s5;
m_jx6=s6;
m_jx7=s7;
status=0;
UpdateData(FALSE);
}
if (status==3)
{
m_sx1=s1;
m_sx2=s2;
m_sx3=s3;
m_sx4=s4;
m_sx5=s5;
m_sx6=s6;
m_sx7=s7;
status=0;
UpdateData(FALSE);
}
return CDialog::PreTranslateMessage(pMsg);
}
void CZSFDlg::OnButtonJdlzshu()
{
// TODO: Add your control notification handler code here
UpdateData();
m_jdlzshu=m_jdl_x*pow(m_jx1,m_jy1)*pow(m_jx2,m_jy2)*pow(m_jx3,m_jy3)*pow(m_jx4,m_jy4)
*pow(m_jx5,m_jy5)*pow(m_jx6,m_jy6)*pow(m_jx7,m_jy7);
UpdateData(FALSE);
}
void CZSFDlg::OnButtonZdlqz()
{
UpdateData();
double u1,u2,u3,w;
u1=(m_z11+m_z12+m_z13)/3;
u2=(m_z21+m_z22+m_z23)/3;
u3=(m_z31+m_z32+m_z33)/3;
w=u1+u2+u3;
m_z1=u1/w;
m_z2=u2/w;
m_z3=u3/w;
UpdateData(FALSE);
}
void CZSFDlg::OnButtonJszdlzsh()
{
// TODO: Add your control notification handler code here
UpdateData();
m_zdl=m_z_xs*pow(m_hlzsh,m_z1)*pow(m_jdlzshu,m_z2)*pow(m_sclzsh,m_z3) ;
UpdateData(FALSE);
}
void CZSFDlg::OnKillfocusEditZ12()
{
UpdateData();
m_z21=1/m_z12;
UpdateData(FALSE);
}
void CZSFDlg::OnKillfocusEditZ13()
{
UpdateData();
m_z31=1/m_z13;
UpdateData(FALSE);
}
void CZSFDlg::OnKillfocusEditZ23()
{
UpdateData();
m_z32=1/m_z23;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -