📄 compiledll_testdlg.cpp
字号:
// CompileDll_testDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CompileDll_test.h"
#include "CompileDll_testDlg.h"
#include "CCompile.h"
#include "CCompileComplex.h"
#include "math.h"
#include "CPUCount.h"
#include <complex>
#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)
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()
/////////////////////////////////////////////////////////////////////////////
// CCompileDll_testDlg dialog
CCompileDll_testDlg::CCompileDll_testDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCompileDll_testDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCompileDll_testDlg)
m_cmA = _T("");
m_cmB = _T("");
m_cmC = _T("");
m_cmCount = _T("");
m_cmCPUCount = _T("");
m_cmD = _T("");
m_cmText = _T("");
m_cmValue = _T("");
m_cmcxA = _T("");
m_cmcxB = _T("");
m_cmcxC = _T("");
m_cmcxCount = _T("");
m_cmcxCPUCount = _T("");
m_cmcxD = _T("");
m_cmcxText = _T("");
m_cmcxValue = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCompileDll_testDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCompileDll_testDlg)
DDX_Text(pDX, IDC_EDIT_cm_A, m_cmA);
DDX_Text(pDX, IDC_EDIT_cm_B, m_cmB);
DDX_Text(pDX, IDC_EDIT_cm_C, m_cmC);
DDX_Text(pDX, IDC_EDIT_cm_Count, m_cmCount);
DDX_Text(pDX, IDC_EDIT_cm_CPUCount, m_cmCPUCount);
DDX_Text(pDX, IDC_EDIT_cm_D, m_cmD);
DDX_Text(pDX, IDC_EDIT_cm_Text, m_cmText);
DDX_Text(pDX, IDC_EDIT_cm_Value, m_cmValue);
DDX_Text(pDX, IDC_EDIT_cmcx_A, m_cmcxA);
DDX_Text(pDX, IDC_EDIT_cmcx_B, m_cmcxB);
DDX_Text(pDX, IDC_EDIT_cmcx_C, m_cmcxC);
DDX_Text(pDX, IDC_EDIT_cmcx_Count, m_cmcxCount);
DDX_Text(pDX, IDC_EDIT_cmcx_CPUCount, m_cmcxCPUCount);
DDX_Text(pDX, IDC_EDIT_cmcx_D, m_cmcxD);
DDX_Text(pDX, IDC_EDIT_cmcx_Text, m_cmcxText);
DDX_Text(pDX, IDC_EDIT_cmcx_Value, m_cmcxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCompileDll_testDlg, CDialog)
//{{AFX_MSG_MAP(CCompileDll_testDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_cm, OnBUTTONcm)
ON_BN_CLICKED(IDC_BUTTON_cmcx, OnBUTTONcmcx)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCompileDll_testDlg message handlers
BOOL CCompileDll_testDlg::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
this->m_cmA="1.0000000001";
this->m_cmB="10000000000";
this->m_cmC="3";
this->m_cmD="2.4556";
this->m_cmText="Power(a,b)*b*cosh(2)";
this->m_cmText+=char(13);this->m_cmText+=char(10);
this->m_cmText+="*sinh(d)*min(a,b)+2*3*a/5";
this->m_cmText+=char(13);this->m_cmText+=char(10);
this->m_cmText+="+sin(sqrt(a))*exp(c)/d";
this->m_cmText+=char(13);this->m_cmText+=char(10);
this->m_cmText+="+cos(5)*sin(a)*d";
this->m_cmText+=char(13);this->m_cmText+=char(10);
this->m_cmCount="100000";
this->m_cmValue="";
this->m_cmCPUCount="";
this->m_cmcxA="1.0000000001";
this->m_cmcxB="10000000000*i";
this->m_cmcxC="3+4*i";
this->m_cmcxD="i";
this->m_cmcxText="Sqrt(d)\n";
this->m_cmcxCount="100000";
this->m_cmcxValue="";
this->m_cmcxCPUCount="";
this->UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CCompileDll_testDlg::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 CCompileDll_testDlg::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 CCompileDll_testDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCompileDll_testDlg::OnBUTTONcm()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
CCompile cm;
Extended x,a,b,c,d;
//a.Fld_PI();
//b=sin(a);
//MessageBox(cm.ExtendedToStr(b));
cm.SetText(this->m_cmText,NULL,true);
if (cm.GetErrorCode()!=0)
{
this->m_cmCPUCount="";
this->m_cmValue="编译时发生错误!";
this->UpdateData(FALSE);
return ;
}
cm.SetExteriorParameter("a",&a);
cm.SetExteriorParameter("b",&b);
cm.SetExteriorParameter("c",&c);
cm.SetExteriorParameter("d",&d);
a=CCompile::StrToExtended(this->m_cmA);
b=CCompile::StrToExtended(this->m_cmB);
c=CCompile::StrToExtended(this->m_cmC);
d=CCompile::StrToExtended(this->m_cmD);
cm.RefreshExeAddressCodeInPointer();
long count=atoi(this->m_cmCount);
__int64 t0= CPUCycleCounter();
for (int i=0;i<count;i++)
{
cm.GetValue(&x);
}
t0= CPUCycleCounter()-t0;
this->m_cmCPUCount=CCompile::ExtendedToStr(Extended(t0));
this->m_cmValue=CCompile::ExtendedToStr(x);
this->UpdateData(FALSE);
}
void CCompileDll_testDlg::OnBUTTONcmcx()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
CCompileComplex cmcx;
TComplex x,a,b,c,d;
cmcx.SetText(this->m_cmcxText,NULL,true);
if (cmcx.GetErrorCode()!=0)
{
this->m_cmcxCPUCount="";
this->m_cmcxValue="编译时发生错误!";
this->UpdateData(FALSE);
return ;
}
cmcx.SetExteriorParameter("a",&a);
cmcx.SetExteriorParameter("b",&b);
cmcx.SetExteriorParameter("c",&c);
cmcx.SetExteriorParameter("d",&d);
cmcx.RefreshExeAddressCodeInPointer();
bool strOk=true;
strOk &= CCompileComplex::StrToTComplex(this->m_cmcxA,&a);
strOk &= CCompileComplex::StrToTComplex(this->m_cmcxB,&b);
strOk &= CCompileComplex::StrToTComplex(this->m_cmcxC,&c);
strOk &= CCompileComplex::StrToTComplex(this->m_cmcxD,&d);
if (!strOk)
{
this->m_cmcxCPUCount="";
this->m_cmcxValue="复数参数书写格式有误!";
this->UpdateData(FALSE);
return ;
}
long count=atoi(this->m_cmcxCount);
__int64 t0= CPUCycleCounter();
for (int i=0;i<count;i++)
{
cmcx.GetValue(&x);
}
t0= CPUCycleCounter()-t0;
//x=std::polar(5.0,3.14/2.0);
this->m_cmcxValue=CCompileComplex::TComplexToStr(x);
this->m_cmcxCPUCount=CCompileComplex::ExtendedToStr(Extended(t0));
this->UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -