Sorry
lcircuit2.h
Code:
#if !defined(AFX_LCIRCUIT2_H__8CC450C8_55E8_42D6_BD59_33E28683A1A8__INCLUDED_)
#define AFX_LCIRCUIT2_H__8CC450C8_55E8_42D6_BD59_33E28683A1A8__INCLUDED_
#include "shunt.h"
#include "tcircuit.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// lcircuit2.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// Clcircuit2 dialog
class Clcircuit2 : public CDialog
{
// Construction
public:
Clcircuit2(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Clcircuit2)
enum { IDD = IDD_lcircuit2 };
double m_rvalue;
double m_rnewvalue;
double m_frequency;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Clcircuit2)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Clcircuit2)
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP();
private:
Cshunt shunt;
Ctcircuit tcircuit;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LCIRCUIT2_H__8CC450C8_55E8_42D6_BD59_33E28683A1A8__INCLUDED_)
lcircuit2.cpp
Code:
// lcircuit2.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "lcircuit2.h"
#include "shunt.h"
#include "tcircuit.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Clcircuit2 dialog
Clcircuit2::Clcircuit2(CWnd* pParent /*=NULL*/)
: CDialog(Clcircuit2::IDD, pParent)
{
//{{AFX_DATA_INIT(Clcircuit2)
m_rvalue = 0.0;
m_rnewvalue = 0.0;
m_frequency = 0.0;
//}}AFX_DATA_INIT
}
void Clcircuit2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Clcircuit2)
DDX_Text(pDX, IDC_EDIT1, m_rvalue);
DDX_Text(pDX, IDC_EDIT2, m_rnewvalue);
DDX_Text(pDX, IDC_EDIT3, m_frequency);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Clcircuit2, CDialog)
//{{AFX_MSG_MAP(Clcircuit2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Clcircuit2 message handlers
void Clcircuit2::OnOK()
{
// TODO: Add extra validation here
double R=0;
double newR=0;
double frequency=0;
double q=0;
double pi=3.142857143;
double L=0;
double C=0;
double w=0;
UpdateData(1);
R=m_rvalue;
newR=m_rnewvalue;
frequency=m_frequency * 1000000;
w=2 * pi * frequency;
if (newR>=R)
{
q=sqrt(newR/R-1);
L=q*R/w;
// C=L/(power(R,2)+power((w*L),2));
tcircuit.m_lvalue=L;
tcircuit.m_qvalue=q;
tcircuit.DoModal();
// tcircuit.m_cvalue=C;
}
else
{
q=sqrt(R/newR-1);
shunt.m_value=q;
shunt.DoModal();
}
UpdateData(0);
CDialog::OnOK();
}
shunt.h
Code:
#if !defined(AFX_SHUNT_H__35B5A7B5_EFB0_4B30_80F5_225057AB7B12__INCLUDED_)
#define AFX_SHUNT_H__35B5A7B5_EFB0_4B30_80F5_225057AB7B12__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// shunt.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// Cshunt dialog
class Cshunt : public CDialog
{
// Construction
public:
Cshunt(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Cshunt)
enum { IDD = IDD_DIALOG3 };
double m_value;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Cshunt)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Cshunt)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SHUNT_H__35B5A7B5_EFB0_4B30_80F5_225057AB7B12__INCLUDED_)
shunt.cpp
Code:
// shunt.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "shunt.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Cshunt dialog
Cshunt::Cshunt(CWnd* pParent /*=NULL*/)
: CDialog(Cshunt::IDD, pParent)
{
//{{AFX_DATA_INIT(Cshunt)
m_value = 0.0;
//}}AFX_DATA_INIT
}
void Cshunt::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cshunt)
DDX_Text(pDX, IDC_EDIT1, m_value);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cshunt, CDialog)
//{{AFX_MSG_MAP(Cshunt)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cshunt message handlers
Thank you, i don't know whether these codes can help.