📄 resultshow.cpp
字号:
// ResultShow.cpp : implementation file
//
#include "stdafx.h"
#include "CBA_SYSTEM.h"
#include "ResultShow.h"
#include "CBADlg.h"
#include "Neural_NetWork.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CCBADlg *ptempDlg;
/////////////////////////////////////////////////////////////////////////////
// CResultShow dialog
CResultShow::CResultShow(CWnd* pParent /*=NULL*/)
: CDialog(CResultShow::IDD, pParent)
{
//{{AFX_DATA_INIT(CResultShow)
m_result = _T("");
//}}AFX_DATA_INIT
}
void CResultShow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResultShow)
DDX_Text(pDX, IDC_EDIT1, m_result);
DDX_Control(pDX,IDC_BUTTON2,m_savebutton);
DDX_Control(pDX,IDC_BUTTON1,m_surebutton);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResultShow, CDialog)
//{{AFX_MSG_MAP(CResultShow)
ON_BN_CLICKED(IDC_BUTTON2, OnGetResult)
ON_BN_CLICKED(IDC_BUTTON1, OnSaveMode)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResultShow message handlers
void CResultShow::OnGetResult()
{
// TODO: Add your control notification handler code here
if(ptempDlg->GetHNodes() == NULL ||ptempDlg->GetHNodesPy()==NULL ||ptempDlg->GetONodesPy()==NULL||ptempDlg->GetWeight()==NULL)
{
MessageBox("测试出错,你可能没有正确配置好神经网络模型!",NULL,MB_OK|MB_ICONINFORMATION);
return;
}
UpdateData(TRUE);
float data[120][7];
float num_of_data[1];
//初始化ADO
if(ado.ReadConfigFile("DataConfig.txt"))
{
if(!ado.OnInitADOConn())
{
return;
}
if(ado.GetData(num_of_data,"select count(*) from train_data"))
{
ado.GetData(data[0],"select * from train_data");
}
else
{
MessageBox("数据库中没有训练数据!",NULL,MB_OK|MB_ICONINFORMATION);
ado.ExitConnect();
return;
}
ado.ExitConnect();
tempNetwork.InitNeural_NetWorkLayers(ptempDlg->GetNumberofHlayer());
tempNetwork.InitNeural_NetWork(ptempDlg->GetNumberofIlayerNode(),ptempDlg->GetNumberofOlayerNode(),ptempDlg->GetHNodes(),ptempDlg->GetHNodesPy(),ptempDlg->GetONodesPy(),ptempDlg->GetWeight());
switch(ptempDlg->GetStopModeindex())
{
case 0:
tempNetwork.Train(data[0],num_of_data[0],ptempDlg->GetStopMode());
break;
case 1:
tempNetwork.SK_Train(data[0],num_of_data[0],ptempDlg->GetStopMode());
break;
}
GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
m_result = tempNetwork.GetResult();
UpdateData(FALSE);
}
else
{
MessageBox("数据库连接失败,请检查配置!",NULL,MB_OK|MB_ICONINFORMATION);
return;
}
}
void CResultShow::OnSaveMode()
{
// TODO: Add your control notification handler code here
tempNetwork.ParametersSave(ptempDlg->GetW_Num());
}
BOOL CResultShow::OnInitDialog()
{
CDialog::OnInitDialog();
if(ptempDlg->GetHNodes() == NULL ||ptempDlg->GetHNodesPy()==NULL ||ptempDlg->GetONodesPy()==NULL||ptempDlg->GetWeight())
{
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CResultShow::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(255,255,255)); //设置为白色背景
// TODO: Add your message handler code here
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAPRSTOP);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC mdc;
mdc.CreateCompatibleDC(&dc);
CBitmap *pOldBmp = mdc.SelectObject(&bmp);
dc.BitBlt(3,20,bmpInfo.bmWidth,bmpInfo.bmHeight,&mdc,0,0,SRCCOPY);
dc.SelectObject(*pOldBmp);
CDialog::OnPaint();
// Do not call CDialog::OnPaint() for painting messages
}
HBRUSH CResultShow::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STATIC)
{
// Set the text color to red
hbr = CreateSolidBrush(RGB(255,255,255));
pDC->SetTextColor(RGB(0, 0, 0));
// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object
//hbr = m_brush;
}
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -